title: electron-vue中使用iview 报错this. is readonly的解决办法
toc: false
date: 2019-02-12 19:33:28
categories:
- Web
tags:
- vue
- iview
报大段xxx is readonly
的解决办法
修改.electron-vue
文件夹中的webpack.renderer.config.js
内第22行的
let whiteListedModules = ['vue']
为:
let whiteListedModules = ['vue', 'iview']
即可。
原理:
.electron-vue/webpack.renderer.config.js
Targets electron's renderer process. This configuration handles your Vue application, so it includes vue-loader and many other configurations that are available in the official vuejs-templates/webpack boilerplate.
White-listing Externals
One important thing to consider about this config is that you can whitelist specific modules to not treat as webpack externals. There aren't many use cases where this functionality is needed, but for the case of Vue UI libraries that provide raw *.vue components they will need to be whitelisted, so vue-loader is able to compile them. Another use case would be using webpack aliases, such as setting vue to import the full Compiler + Runtime build. Because of this, vue is already in the whitelist.