语法错误:未知:默认情况下不支持命名空间标签 [英] SyntaxError: unknown: Namespace tags are not supported by default
本文介绍了语法错误:未知:默认情况下不支持命名空间标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试将 svg 作为 React 组件下载时出现以下错误.
I get the following error when trying to download svg as a React Component.
语法错误:未知:默认情况下不支持命名空间标记.React 的 JSX 不支持命名空间标签.您可以打开throwIfNamespace"标志来绕过此警告.
SyntaxError: unknown: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can turn on the 'throwIfNamespace' flag to bypass this warning.
import React from "react";
import { ReactComponent as LO } from "../a/Logo.svg"
import { NavLink } from "react-router-dom";
const Logo = () => (
<>
<NavLink to={"/"}>
<LO width={"40px"} height={"40px"} />
</NavLink>
</>
);
export default Logo;
是什么原因?
推荐答案
在 SVG 文件中,尝试更改:
sketch:type TO sketchType
xmlns:xlink TO xmlnsXlink
xlink:href TO xlinkHref
等等...
这个想法是创建camelCase属性,请记住您正在使用JSX,而不是像XML那样创建字符串.
The idea is to create camelCase property, remember that you are working with JSX, you are not creating a string as XML does.
这篇关于语法错误:未知:默认情况下不支持命名空间标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文