主要原因是安装的jquery版本和ztree中的版本不匹配。
1、配置package.json:
"dependencies": { "axios": "^0.19.2", "bootstrap": "^3.4.1", "bootstrap-table": "^1.11.1", "bootstrap-validator": "^0.11.9", "bootstrapvalidator": "^0.5.4", "echarts": "^4.2.1", "element-ui": "^2.13.2", "jquery": "^3.3.1", "popper.js": "^1.16.1", "vue": "^2.5.2", "vue-router": "^3.0.1", "vuex": "^3.1.0", "ztree": "^3.5.24" }
2、build/webpack.base.conf.js中配置ProvidePlugin:
module.exports = { plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", 'window.jQuery': 'jquery', jQuery: 'jquery' }) ] }
3、main.js中引入ztree:
import 'ztree' import 'ztree/css/metroStyle/metroStyle.css'