Vue-cli3项目中不支持element-ui中的render-content写法

基础平台升级后babel.config.js修改为
```module.exports = {
presets: [
"@babel/preset-env"
]
}
```

会导致项目运行不了,因为很多项目中用到了element-ui中的render-content方法

```
renderContent(h, { node, data, store }) {
return (
<span class="custom-tree-node">
<span>{node.label}</span>
<span>
<el-button size="mini" type="text" on-click={ () => this.append(data) }>Append</el-button>
<el-button size="mini" type="text" on-click={ () => this.remove(node, data) }>Delete</el-button>
</span>
</span>);
}
```
这种需要安装babel插件
```babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
```
babel.config.js修改为
```module.exports = {
presets: [
"@babel/preset-env"
],
plugins:['transform-vue-jsx']
}
```
然而最简单的方法就是讲babel.config.js修改为
```
module.exports = {
presets: [
'@vue/app'
]
}
```
posted @ 2020-08-06 14:41  你丫才美工  阅读(3403)  评论(0编辑  收藏  举报