在内联 svg 标签上使用 viewBox 属性 时出现 WebStorm 警告
WebStorm warning when using viewBox property on an inline svg tag
我使用带有 viewBox 属性的 SVG 标签,内嵌在 HTML 文件中。
<!doctype html>
<html><!-- ... ---><body>
<!-- ... -->
<svg viewBox="0 0 17 17">
<!-- ... -->
</svg>
<!-- ... -->
</body></html>
尽管它正在工作(并且这里是必需的),但 WebStorm 给了我一个警告:
Attribute viewBox is not allowed here
是我做错了什么还是只是 WebStorm 中的错误?
请尝试将命名空间属性添加到 svg 标签,例如 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17">
- 这应该可以解决问题。根据specification、"in all cases, for compliance with the Namespaces in XML Recommendation [XML-NS], an SVG namespace declaration must be provided so that all SVG elements are identified as belonging to the SVG namespace."
我使用带有 viewBox 属性的 SVG 标签,内嵌在 HTML 文件中。
<!doctype html>
<html><!-- ... ---><body>
<!-- ... -->
<svg viewBox="0 0 17 17">
<!-- ... -->
</svg>
<!-- ... -->
</body></html>
尽管它正在工作(并且这里是必需的),但 WebStorm 给了我一个警告:
Attribute viewBox is not allowed here
是我做错了什么还是只是 WebStorm 中的错误?
请尝试将命名空间属性添加到 svg 标签,例如 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17">
- 这应该可以解决问题。根据specification、"in all cases, for compliance with the Namespaces in XML Recommendation [XML-NS], an SVG namespace declaration must be provided so that all SVG elements are identified as belonging to the SVG namespace."