vue-jstree在这里https://github.com/zdy1988/vue-jstree
我是vue-cli建的项目
npm install vue-jstree --save
组件里这样写
import VJstree from 'vue-jstree'; import axios from "axios"; export default { name: 'Mytree', components: { VJstree }, data() { return { data: [] } }, created() { axios.get('http://192.168.x.x/a2hs/treedata.php') .then(response => { this.data=response.data; }) .catch(e => { console.log(e) }); },
动态返回的JSON数据格式如下
[{"id":1,"pid":0,"text":"node1","opened":0,"children":[{"id":43,"pid":1,"text":"node2","opened":0}...]}...]
如果有跨域问题,treedata.php输出前加
header('Access-Control-Allow-Origin: *');
我是vue-cli建的项目
npm install vue-jstree --save
组件里这样写
import VJstree from 'vue-jstree'; import axios from "axios"; export default { name: 'Mytree', components: { VJstree }, data() { return { data: [] } }, created() { axios.get('http://192.168.x.x/a2hs/treedata.php') .then(response => { this.data=response.data; }) .catch(e => { console.log(e) }); },
动态返回的JSON数据格式如下
[{"id":1,"pid":0,"text":"node1","opened":0,"children":[{"id":43,"pid":1,"text":"node2","opened":0}...]}...]
如果有跨域问题,treedata.php输出前加
header('Access-Control-Allow-Origin: *');