Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.svg undefine #36

Open
moox2020 opened this issue Nov 23, 2022 · 0 comments
Open

xml.svg undefine #36

moox2020 opened this issue Nov 23, 2022 · 0 comments

Comments

@moox2020
Copy link

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

<script> import myicon from 'vue-svg-icon/Icon.vue' export default { name: 'App', components: { myicon } } </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant