Module parse failed: Unexpected character '#'

项目运行出现该错误提示。
ERROR in ./src/App.vue?vue&type=style&index=0&lang=css
Module parse failed: Unexpected character '#' (26:0)
You may need an appropriate loader to handle this file type.
图片描述

图片描述

阅读 13.1k
2 个回答

Vue Loader v15 now requires an accompanying webpack plugin to function properly:

// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = {
  // ...
  plugins: [
    new VueLoaderPlugin()
  ]
}

vue-loader@15.*之后除了必须带有VueLoaderPlugin 之外,还需另外单独配置css-loader。

const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.css$/,
        use: ['style-loader','css-loader']
      }
    ]
  }
  plugins: [
    new VueLoaderPlugin()
  ]
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题