vue-svg-icon
vue-svg-icon copied to clipboard
xml.svg undefine
vue.runtime.esm.js?c320:3049 TypeError: Cannot read properties of undefined (reading '$') at VueComponent.icon (Icon.vue?539a:78:1)
对应的代码:
icon() {
let xml = require(!xml-loader!../../src/svg/${this.name}.svg
);
const t = xml.svg.$.viewBox.split(' ');
// 这里报错,xml存在,但xml.svg undefine ,xml.svg.$ 自然也undefine
console.info(src/svg/${this.name}.svg has been loaded
);
return {
width: t[2],
height: t[3],
paths: convert.SVGtoArray(xml.svg)
}
},
我的代码:已正常 npm install vue-svg-icon --save-dev