vue2使用pinia在main.js中导入报错

./node_modules/pinia/dist/pinia.mjs 1147:44-52
Can’t import the named export ‘computed’ from non EcmaScript module (only default export is available)
解决办法1:

// vue.config.js
module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.mjs$/,
          include: /node_modules/,
          type: "javascript/auto"
        }
      ] 
    }
  }
}

解决办法2:

import { createPinia, PiniaVuePlugin } from 'pinia/dist/pinia.cjs';

你可能感兴趣的:(pinia,vue,javascript,vue.js,前端)