1、下载安装依赖包

npm install babel-plugin-syntax-jsx babel-plugin-transform-vue-jsx babel-helper-vue-jsx-merge-props babel-preset-env --save-dev

2、项目根目录下新建 .babelrc 文件,并写入代码

{
    "presets": [
        ["env", {
            "modules": false,
            "targets": {
                "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
            }
        }],
        "stage-2"
    ],
    "plugins": ["transform-runtime","transform-vue-jsx"],
    "env": {
        "test": {
            "presets": ["env", "stage-2"],
            "plugins": ["transform-vue-jsx","istanbul"]
        }
    }
}

3、html

<el-tree
    :data="item.children"
    :render-content="renderContent">
</el-tree>

4、js

methods: {
    renderContent(h, {node, data, store}){
      return (
        <span></span>
      );
    },
    other(){
        // some code
    },
    .......
    .......
}

 

Logo

前往低代码交流专区

更多推荐