javascript - 调整窗口大小时,svelte/sapper 中的 InvalidCharacterError
问题描述
我用工兵建立了一个网站。当我调整窗口大小(变小,然后又变大)时,我在 Firefox 中收到此错误:
String contains an invalid character in svelte
在文件index.mjs:249中。单击文件会导致此功能:
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
错误似乎就在这里:node.setAttribute(attribute, value);
有人知道可能导致此错误的原因吗?我有一些条件逻辑来根据窗口大小显示组件:
<script>
let windowSize;
</script>
<svelte:window bind:innerWidth={windowSize} />
{#if windowSize >= 768}
<Image />
{/if}
这会导致错误吗?
更新
谷歌浏览器抛出此错误:
Uncaught (in promise) DOMException: Failed to execute 'setAttribute' on 'Element': '`rel' is not a valid attribute name.
解决方案
解决它。标记的属性中有一个反引号 (`) <a />
:
<a
`rel="noreferrer"
aria-label={external}
class="social-media-icon"
target="_blank"
href={external}>
推荐阅读
- php - 如何使用 Youtube Data API 将某些电子邮件地址添加到允许列表以访问我的私人 youtube 视频?
- machine-learning - 在多类分类的情况下应该如何处理不平衡类
- python - 乘法和添加权重networkx图python
- c# - 以编程方式触发触觉时,Vive 控制器上发出奇怪的哔哔声(Unity3D / SteamVR 2.0)
- xamarin - 无法转换任务
布尔在 Xamarin 窗体 CrossConnectivity 插件? - hive - 如何解析地图
使用mapreduce从具有RCFile存储格式的HDFS? - excel - 将数字与随机字母和数字的文本字符串完全匹配
- python - 我无法在 django 2.1.4 中为应用程序进行迁移
- spring - HTTP 400 错误未在 Spring Boot 中登录,尽管 404 和其他错误
- github - IntelliJ,无法在 GitHub 上共享项目(权限被拒绝)