vue-jstree 绑定
时间: 2023-07-07 12:45:20 浏览: 78
要在Vue中使用jstree,你需要先安装jstree插件。可以通过npm安装:
```
npm install jstree --save
```
然后你可以在Vue组件中使用jstree。你需要在Vue组件的`mounted`钩子中初始化jstree,然后在`beforeDestroy`钩子中销毁jstree。以下是一个简单的示例:
```
<template>
<div id="jstree"></div>
</template>
<script>
import 'jstree/dist/themes/default/style.css';
import 'jstree';
export default {
mounted() {
$('#jstree').jstree({
'core': {
'data': [
{
'text': 'Node 1',
'children': [
{ 'text': 'Child 1' },
'Child 2'
]
},
'Node 2'
]
}
});
},
beforeDestroy() {
$('#jstree').jstree('destroy');
}
}
</script>
```
这里使用了jQuery,如果你不想使用jQuery,可以使用jstree提供的无依赖版本。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)