使用SVG对象的onloadwff中的TypeError

Fre*_*rck 5 html javascript svg google-chrome webfonts

我正在尝试在网页上显示SVG图像。SVG图像包含自定义字体。为了使Chrome(和其他浏览器)加载SVG中使用的WebFont,我在SVG中添加了以下内容。

<defs>
    <style>
        @import url('https://fonts.googleapis.com/css?family=<font>');
    </style>
</defs>
Run Code Online (Sandbox Code Playgroud)

通过添加对象元素将图像添加到HTML页面。这在加载字体并在Chrome和Firefox中使用定义的WebFont渲染图像中的文本时起作用。

但是在Chrome中,控制台中会记录以下错误:

Uncaught (in promise) TypeError: Cannot read property 'querySelectorAll' of null
    at e.getInputs (onloadwff.js:71)
    at e.<anonymous> (onloadwff.js:71)
    at onloadwff.js:71
    at Object.next (onloadwff.js:71)
    at a (onloadwff.js:71)
Run Code Online (Sandbox Code Playgroud)

我曾尝试寻找类似的问题,但未能找到答案。关于Chrome中可能出现的问题或如何进一步调查该问题的任何想法?

小智 11

我遇到了与此相同的问题,根本原因是来自Chrome扩展程序LastPass。删除它对我有用。

报告了该错误:https : //forums.lastpass.com/viewtopic.php?f=12&t=323095&p=1080525&hilit=Cannot+read+property+%27querySelectorAll%27+of+null#p1080525

希望它会有所帮助。


Fre*_*ers 5

也遇到了这个问题,对我来说也是 LastPass 造成的。

如果您不想删除或禁用 LastPass,您可以右键单击控制台中的错误,然后选择隐藏来自该脚本的错误消息。

在此输入图像描述