【问题标题】:Vuetify - Error "You may need an additional loader to handle the result of these loaders."Vuetify - 错误“您可能需要一个额外的加载器来处理这些加载器的结果。”
【发布时间】:2022-11-06 03:58:34
【问题描述】:

我正在使用 Materio 模板 Vuetify 和 Babel。

我最初使用 yarn serve 提供模板。 包完成构建后,我收到了几个错误,表明我必须使用额外的加载器。

这是 vue.config.js :

const path = require('path')
const { mergeSassVariables } = require('@vuetify/cli-plugin-utils')

module.exports = {
  publicPath: '/',
  transpileDependencies: ['vuetify'],
  configureWebpack: {
    resolve: {
      alias: {
        '@themeConfig': path.resolve(__dirname, 'themeConfig.js'),
        '@core': path.resolve(__dirname, 'src/@core'),
        '@axios': path.resolve(__dirname, 'src/plugins/axios.js'),
        '@user-variables': path.resolve(__dirname, 'src/styles/variables.scss'),
      },
    },
  },
  chainWebpack: config => {
    const modules = ['vue-modules', 'vue', 'normal-modules', 'normal']
    modules.forEach(match => {
      config.module
        .rule('sass')
        .oneOf(match)
        .use('sass-loader')
        .tap(opt => mergeSassVariables(opt, "'@/styles/variables.scss'"))
      config.module
        .rule('scss')
        .oneOf(match)
        .use('sass-loader')
        .tap(opt => mergeSassVariables(opt, "'@/styles/variables.scss';"))
    })
  },
}

这是 babel.config.js :

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
  ],
}

正如你在下面看到的,我收到了这个错误

Module parse failed: Unexpected token (806:65)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     // add message template
|     async saveMessageTemplate() {
>       this.formAddTemplate.attachments = this.$refs['uppy-data']?.uppy?.getFiles();
|       this.on_reply_message.attachments = this.$refs['uppy-data-onreply']?.uppy?.getFiles();
|       this.formAddTemplate.id = uuidv4();

【问题讨论】:

  • 嘿 Muhammad 你能告诉我你的操作系统设备是什么吗?
  • 我正在使用 Windows 10 专业版

标签: javascript node.js vue.js webpack babeljs


【解决方案1】:

babel.config.js

module.exports = {
  presets: ['@vue/cli-plugin-babel/preset'],
  plugins: [
    '@babel/plugin-proposal-optional-chaining'
  ]
};

【讨论】:

    【解决方案2】:

    您使用的加载器可能不支持可选链接,因此请从代码中删除可选链接,如下所示并尝试。或者使用最新的 Loader 配置您的项目。

    异步 saveMessageTemplate() {

      this.formAddTemplate.attachments = this.$refs['uppy-data'].uppy.getFiles();
    

    | this.on_reply_message.attachments = this.$refs['uppy-data-onreply'].uppy.getFiles(); | this.formAddTemplate.id = uuidv4();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-04
      • 2020-04-05
      • 2020-09-12
      • 2021-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多