添加Google Fonts字体时出现'expected named entity'错误的修复咨询
修复Google Fonts引入时的"expected named entity, got none"错误
这个报错的核心原因是HTML语法要求:&作为特殊字符必须转义为&,你复制的代码最后一行URL里的&display=swap没有做转义,导致HTML解析器无法识别,抛出实体错误。
修复后的代码如下:
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@0,100..700;1,100..700&display=swap" rel="stylesheet">
只需将原代码中URL里的&替换为&即可解决问题,HTML解析器会正确处理转义后的字符,不再报错。
内容的提问来源于stack exchange,提问作者Raine
相关产品推荐
相关产品推荐

