webpack 如何处理通过 `js` 引入的资源文件加载问题??

相关配置:

项目路径:/var/website/test
目录结构:
compiled
source
    components        public
            public.vue    static
        image
            test.png
    plugins    // ...static

假设在一个 source/components/public/public.vue 文件中,通过 js 引入了一个文件:

<template>
    <section>
        <img ref='test' src='' class='image'>
    </section></template><script>export default {    name: '' , 
    mounted () {        this.$refs.test.src='../../static/image/test.png';
    }
};</script>

webpack 打包后,访问不到资源!!

webpack 如何处理通过 js 引入的资源文件加载问题??


MMMHUHU
浏览 929回答 2
2回答

翻阅古今

先import再使用import&nbsp;src&nbsp;from&nbsp;'../../static/image/test.png';export&nbsp;default&nbsp;{ &nbsp;&nbsp;name:&nbsp;'', &nbsp;&nbsp;mounted()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;this.$refs.test.src&nbsp;=&nbsp;src; &nbsp;&nbsp;} };

30秒到达战场

webpack引入图片等其他资源也必须是require或者import(最终也会转成require)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript