nuxtjs typescript [Vue error]
listeners is readonly.
这个问题主要是由于 Vue 被多次引用造成的,
在 nuxtjs config 文中 build 中添配置如下:
nuxt.config.ts
build: {
extend(config, {isClient}) {
// Extend only webpack config for client-bundle
if (isClient) {
config.devtool = 'source-map'
}
config.resolve.alias['vue'] = path.resolve('./node_modules/vue')
},
....
},
另外如果项目是 vue spa 项目,可以用以下方式解决
// app/webpack.config.js
const path = require('path')
module.exports = {
//...
resolve: {
symlinks: false,
alias: {
'vue$': 'vue/dist/vue.runtime.esm.js',
}
}
}
or
// resolve: {
// alias: {
// 'vue': path.resolve('./node_modules/vue')
// }
// },
网友评论