SyntaxError: "undefined" is not valid JSON
file:[console]
SyntaxError: "undefined" is not valid JSON
下面是我写的一个组件,其中 attrs 属性需要传递一个 JSON 字符串。JSON 数据本身的键是双引号,上述的报错可能就是因此导致的。
file:[Example.vue]
<SVG :attrs="item.attrs"></SVG>
所以,最好还是以对象传递,如下所示。
file:[Example.vue]
<SVG add:[:attrs="JSON.parse(item.attrs)"></SVG>]:add