Commit f85c8bdf authored by JingChao's avatar JingChao

tab添加切换活跃的函数

parent 2b461f12
...@@ -78,9 +78,21 @@ export default { ...@@ -78,9 +78,21 @@ export default {
setTimeout(() => { setTimeout(() => {
this.items[vm.current].$el.classList.add('activated') this.items[vm.current].$el.classList.add('activated')
}, 100) }, 100)
this.$emit('input', vm.current)
this.scrollToActiveTab(vm.current, this.items[vm.current].$el.clientWidth) this.scrollToActiveTab(vm.current, this.items[vm.current].$el.clientWidth)
}, },
methods: { methods: {
setTabActive (index) {
let vm = this
vm.items.forEach(item => {
item.$el.classList.remove('activated')
})
setTimeout(() => {
this.items[index].$el.classList.add('activated')
}, 100)
let width = this.items[index].$el.clientWidth
this.actived(index, width)
},
actived (index, clientWidth) { actived (index, clientWidth) {
this.activedIndex = index this.activedIndex = index
this.$emit('tabClick', index) this.$emit('tabClick', index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment