cenkai88 / vue-svg-icon

a solution for multicolor svg icons in vue2.0 (vue2.0的可变彩色svg图标方案)
https://cenkai88.github.io/vue-svg-icon/demo/
Other
562 stars 84 forks source link

xml.svg undefine #36

Open moox2020 opened 1 year ago

moox2020 commented 1 year ago

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