vue甘特图
npm install dhtmlx-gantt --save安装甘特图到自己的项目内之后可以创建一个vue文件<template><div ref="gantt"></div></template><script>import 'dhtm
npm install dhtmlx-gantt --save
安装甘特图到自己的项目内
之后可以创建一个vue文件
<template>
<div ref="gantt"></div>
</template>
<script>
import 'dhtmlx-gantt'
export default {
name: 'gantt',
props: {
tasks: {
type: Object,
default () {
return {data: [], links: []}
}
}
},
mounted: function () {
gantt.init(this.$refs.gantt)
gantt.parse(this.$props.tasks)
}
}
</script>
<style>
@import "~dhtmlx-gantt/codebase/dhtmlxgantt.css";
</style>
打开App.vue并添加以下代码
<template>
<div class="container">
<gantt class="left-container" :tasks="tasks"></gantt>
</div>
</template>
<script>
import Gantt from './components/Gantt.vue';
export default {
name: 'app',
components: {Gantt},
data () {
return {
tasks: {
data: [
{id: 1, text: 'Task #1', start_date: '15-04-2017', duration: 3, progress: 0.6},
{id: 2, text: 'Task #2', start_date: '18-04-2017', duration: 3, progress: 0.4}
],
links: [
{id: 1, source: 1, target: 2, type: '0'}
]
},
}
}
}
</script>
我们应该在页面上能够看到带有预定义任务的甘特图,如果没有可以在标签上添加高度
更多推荐
所有评论(0)