VUE组件懒负载SVG
我试图在我的组件加载时试图lazy加载SVG,但是运行npm运行手表
,并且组件尝试构建它正在尝试找到此文件,当然,当组件被汇总到路径上时是懒惰的加载会有所不同,因此目前我遇到了一个错误,指出它无法找到文件。
我的组件将汇编为public_html/Assets/js/chunks/[hash] .js
,我的SVG将在public> public_html/assets/icons/icons/icons/manducturer.svg
之内。
如何停止尝试编译路径并仅将其加载到负载上?
// component
computed: {
icon() {
const icons = {
manufacturer: () => import('../../icons/manufacturer.svg')
}
return icons['manufacturer'];
},
im trying to lazy load an SVG when my component loads, however when running npm run watch
and the component attempts to build it is trying to find this file, of course when the component is compiled down the path it is lazy loading will be different, so i'm getting an error at the moment stating it's unable to locate the file.
My component will compile down to public_html/assets/js/chunks/[hash].js
, and my SVG will be within public_html/assets/icons/manufacturer.svg
.
How can I stop it trying to compile the path and only load it on load?
// component
computed: {
icon() {
const icons = {
manufacturer: () => import('../../icons/manufacturer.svg')
}
return icons['manufacturer'];
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论