Comments (5)
Thank you @robinsandstrom, it helped me!
My mistake was in passing my component to each h
function.
from vue-org-tree.
renderContent: function(h, data) {
return h(MyVueComponent, {
props: {
foo: bar,
bar: foo
},
});
}
Try this and you should be able to use any component as a node!
from vue-org-tree.
Thanks @robinsandstrom !
I am tried this
Component TreeNodePerson
:
<template>
<div class="class">
</div>
</template>
<script>
import store from "../store";
export default {
props:['className', 'width'],
data() {
return {
}
},
mounted() {
},
methods: {
},
computed: {
class () {
return this.$props.className;
}
}
}
</script>
and updated render function:
return h(TreeNodePerson, {
props: {
className: className
}
}, [h(TreeNodePerson, {
props: {
className: cls.join(' '),
width: labelWidth,
},
}, childNodes)])
But unfortunately components are not rendering
from vue-org-tree.
<template>
<section>
<div class="content">
<vue-org-tree
:data="data"
:props="dataprops"
:horizontal="horizontal"
:collapsable="collapsable"
:render-content="renderContent"
@on-expand="onExpand"
@on-node-click="onNodeClick"/>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import { mapGetters } from 'vuex'
import Node from '@/components/Node'
export default {
components: { Node },
data () {
return {
data: { 'name': 'Company 1', 'business_id': 10, children: [] },
horizontal: true,
collapsable: true,
expandAll: true,
labelClassName: 'bg-white',
dataprops: {
label: 'id',
expand: 'expand',
children: 'children'
}
}
},
methods: {
renderContent: function(h, data) {
return h(CompanyNode, {
props: {
label: data.name,
value: data.business_id
},
});
},
onExpand: function(e, data) {
if ('expand' in data) {
data.expand = !data.expand
if (!data.expand && data.children) {
this.collapse(data.children)
}
} else {
this.$set(data, 'expand', true)
}
},
onNodeClick: function(e, data) {
this.$router.push({ name: 'Business', params: { id: data.id }})
},
collapse: function(list) {
var _this = this
list.forEach(function(child) {
if (child.expand) {
child.expand = false
}
child.children && _this.collapse(child.children)
})
},
expandChange: function() {
this.toggleExpand(this.data, this.expandAll)
},
toggleExpand: function(data, val) {
var _this = this
if (Array.isArray(data)) {
data.forEach(function(item){
_this.$set(item, 'expand', val)
if (item.children) {
_this.toggleExpand(item.children, val)
}
})
} else {
this.$set(data, 'expand', val)
if (data.children) {
_this.toggleExpand(data.children, val)
}
}
}
}
}
</script>
With Node:
<template>
<section>
<div class="has-text-left">
<p class="is-size-5 py-0 my-0 has-text-weight-medium has-text-black">{{ label }}</p>
<p class="py-0 my-0 is-size-6 mt-0">{{ value }}</p>
</div>
</section>
</template>
<script>
export default {
props: {
label: String,
value: String
}
}
</script>
from vue-org-tree.
Great to hear :)
from vue-org-tree.
Related Issues (20)
- 不知道作者可否提供一个将末端节点连线合并的思路? HOT 1
- renderContent does not support html HOT 1
- Cannot display child on first load HOT 1
- 节点添加html标签,添加element-ui 组件(比如下拉选择,时间框等等) HOT 1
- 如果节点内容存在 SVG 内容,控制台报错。
- 能否加个父节点的功能,有双向展开就更好了
- 是否考虑支持级联复选功能
- 怎么在一个泡泡内展示多个字段可以换行的那种 HOT 1
- 一直不显示样式
- 想请教一下,5000个节点展示时的性能如何
- Erro na Implementacao Vue3-blocks-tree
- 请问下,最新版本1.3.5 Pan和zoom 属性失效
- 请问是否考虑增加插槽功能?
- vue-ork-tree??? HOT 1
- Could not resolve "./org-tree"
- 层级结构样式丢失
- 能适配下vue3吗
- 样式问题 HOT 1
- Cannot render tree
- add new node to selected node
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-org-tree.