我在从 npm 加载 css 文件与从 cdn 加载时遇到问题。
使用下面的 CDN,我能够毫无问题地呈现表单。
<link rel='stylesheet' href='https://unpkg.com/formiojs@latest/dist/formio.full.min.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/formiojs@3.9.3/dist/formio.full.min.css' />
但是当我从本地 CSS 文件呈现表单时,表单呈现不正确
<link rel='stylesheet' src="/lib/formiojs/dist/formio.full.min.css" asp-append-version="true"/>
你可以看出区别here
在浏览器中打开这 2 个文件并粘贴到 diff 工具中,我注意到差异似乎在位于 2 个位置的 '×'
附近。
在文本编辑器中打开这 2 个文件时,它们是相同的。
在浏览器中,CDN 将字符串呈现为 '×'
但 npm 文件呈现为 '×'
。
如何使用'×'
加载CSS文件?
我已经尝试将 charset="UTF-8"
添加到 link
元素,但它仍然无法正确呈现。
我认为这与编码有关。
有问题的文件可以在这里找到 https://github.com/formio/formio.js/blob/master/dist/formio.full.css
最佳答案
这可能是一个打字错误,但你可以尝试替换
<link rel='stylesheet' src="/lib/formiojs/dist/formio.full.min.css" asp-append-version="true"/>
与
<link rel='stylesheet' href="/lib/formiojs/dist/formio.full.min.css" asp-append-version="true"/>
关键区别是 href
用于代替 src
.
关于html - 浏览器以不同方式呈现相同的 css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53728927/