[英]How do you include an assets folder in a Vue file?
I tried this (I'm using Vue's official Webpack template ): 我试过这个(我正在使用Vue的官方Webpack模板 ):
data () {
photoEditorAssets: require('../assets/img/photoeditorsdk/assets'),
}
mounted () {
var editor = new PhotoEditorSDK.UI.DesktopUI({ //eslint-disable-line
container: container,
assets: {
baseUrl: this.photoEditorAssets // <-- This should be the absolute path to your `assets` directory
}
})
}
}
However, I get this error: 但是,我收到此错误:
Module build failed: Error: ENOENT: no such file or directory, open 'E:\\alex\\vreditor\\src\\assets\\img\\photoeditorsdk\\assets'
模块构建失败:错误:ENOENT:没有这样的文件或目录,打开'E:\\ alex \\ vreditor \\ src \\ assets \\ img \\ photoeditorsdk \\ assets'
Maybe the code is searching for a file called assets? 也许代码正在搜索名为assets的文件?
How to properly import a folder in a Vue file? 如何正确导入Vue文件中的文件夹?
Note: Here's the structure of my project: 注意:这是我项目的结构:
That's not how require()
works. 这不是
require()
工作原理。 What you want is only the absolute path. 你想要的只是绝对的道路。
Simply something like this should work for you. 这样的事情应该适合你。
data () {
photoEditorAssets: '../assets/img/photoeditorsdk/assets',
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.