javascript - ie11 上的 sl-vue-tree + vue-cli3.1
问题描述
我是日本人,我不擅长英语对不起。
我正在使用 vue-cli3.1。
我想在 ie11 上使用这个模块。 https://github.com/holiber/sl-vue-tree
它说你可以在 ie11 上使用 babel-polyfil。
但我不能正确使用 babel-polyfil。
我做了“纱线添加@babel/polyfill”。
我在 main.ts 的顶部导入了它。
但它没有用。
import "@babel/polyfill"
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
Vue.config.productionTip = false;
new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app');
<template>
<div class="about">
<h1>This is an about page</h1>
<SlVueTree v-model="treeModel">
</SlVueTree>
</div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
//sl-vue-tree
import SlVueTree from "sl-vue-tree-original";
@Component({
components: {
SlVueTree
}
})
export default class About extends Vue {
public treeModel = [
{
"title": "Item1",
"isLeaf": true
},
{
"title": "Item2",
"isLeaf": true
},
{
"title": "Folder1",
"isExpanded": true,
"children": [
{
"title": "Item3",
"isLeaf": true
},
{
"title": "Item4",
"isLeaf": true
},
{
"title": "Folder2",
"children": [
{
"title": "Item5",
"isLeaf": true
}
]
}
],
"isSelected": true
},
{
"title": "Item6",
"isLeaf": true
}
];
}
}
</script>
解决方案
这就是我解决它的方法。我正在使用 Vue cli 3.6 和 sl-vue-tree 1.8.4
将 transpileDependencies 添加到 vue.config.js
module.exports = {
transpileDependencies: ['sl-vue-tree'],
...
}
我的 babel.config.js
module.exports = {
presets: [
["@vue/app", {
modules: "commonjs"
}]
]
};
在我的 vue 组件中,我只是像这样导入 sl-vue-tree:
import slVueTree from "sl-vue-tree";
推荐阅读
- python - 如何从 for 循环内的不同列表中选择项目?
- linux - vbus 调节器设备树
- python - python socket,HTTPS请求加载完整的html代码
- sharepoint-online - 在 SharePoint Online 中使用 ADAL 对 Yammer JS SDK 进行身份验证
- npm - 通过 npm 将 Bootstrap4 添加到 Symfony4 项目
- reactjs - 如何在通常的网站中呈现 React 组件
- c# - Windows 工作流可以用 C# 而不是 XAML 编写吗?
- vba - For 循环使用日期编译错误:语法错误
- python - 遍历位于不同文件夹中的文件
- javascript - 灯廊更新索引