1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <template> <div class="home"> <TimeLine :pages="pageList" ref="timeline"></TimeLine> <ul> <li v-for="(page,p) in pageList" :class="['btn',{'active':activeIndex===p}]" @click="swicthPage(p)">{{p}} </li> <li @click="zoomIn" class="btn">放大</li> <li @click="zoomOut" class="btn">缩小</li> <li @click="back" class="btn">重置</li> </ul> </div> </template> <script> import {TimeLine} from 'vue-time-line-npm';
export default { data() { return { activeIndex: 0, pageList: [{ id: 1, name: "页签1", duration: 3, }, { id: 2, name: "页签2", duration: 3, }, { id: 3, name: "页签3", duration: 3, }] } }, components: { TimeLine }, methods: { swicthPage(index) { this.activeIndex = index; this.$refs.timeline.switchPage(index); }, zoomOut() { this.$refs.timeline.zoomOut(); }, zoomIn() { this.$refs.timeline.zoomIn(); }, back() { this.$refs.timeline.backHome(); }, } } </script> <style scoped lang="scss"> ul, li { list-style: none; }
li { display: inline-flex; }
.btn { padding: 10px 20px; border: 1px solid; margin: 0 10px; cursor: pointer;
&.active { background-color: #f60; color: #fff; } } </style>
|