【发布时间】:2019-01-17 15:24:24
【问题描述】:
我目前在名为“/pictures”的静态目录中设置了一个图像文件夹
我从 webpacks 网站获取了模板代码,但是当我尝试编译时出现以下错误:
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
我已附上我的代码供参考,希望有人能提供帮助!对于上下文,我在我的 vue.js 应用程序的一个组件中运行代码
data () {
return {
imageDir: "../../static/pictures/",
images: {}
}
},
firebase: {
homePageNotifs : homePageNotifsRef
},
mounted(){
this.importAll(require.context(this.imageDir, true, /\.png$/))
},
methods: {
importAll(r) {
var imgs = {}
r.keys().forEach(key => (imgs[key] = r(key)))
this.images = imgs
}
}
【问题讨论】: