简体   繁体   English

如何在Vue文件中包含资源文件夹?

[英]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.

相关问题 如何在 Vue 中加载 YAML 文件? - How do you load a YAML file in Vue? 你如何使用 webpack 包含整个 polyfills 文件夹? - How do you include an entire folder of polyfills using webpack? Rails 3.1 - 如何在vendor / assets / javascript中包含外部JavaScript库? - Rails 3.1 - How do you include external javascript libraries in vendor/assets/javascript? 如何在Vue路由器路径中包含文件夹名称 - How to include folder name in vue router path 我如何拥有一个可以在我的 React 应用程序中的任何文件中使用的资产文件,而不必总是导航到资产文件夹 - How do i have an assets file that i can use in any file in my react app without always having to navigate to the assets folder Vue.js:如何在.vue模板文件内的vue方法中设置数据变量 - Vue.js: how do you set a data variable in a vue method inside a .vue template file 如何在测试文件中包含 Typescript 命名空间? - How do you include a Typescript namespace in a test file? 如何使multer将文件保存在文件夹中? - How do you make multer save the file in a folder? Rails递归地包含javascripts资源文件夹 - Rails include javascripts assets folder recursively Codeigniter-如何将JSON传递到资产文件夹中的JS文件? - Codeigniter - How to pass JSON to JS file in assets folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM