|
|
|
|
@ -27,10 +27,18 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
activeIndex: this.current,
|
|
|
|
|
targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id
|
|
|
|
|
// activeIndex: this.current, // 改用computed计算属性
|
|
|
|
|
// targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id(改用computed计算属性)
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
activeIndex() {
|
|
|
|
|
return this.current;
|
|
|
|
|
},
|
|
|
|
|
targetScrollId() {
|
|
|
|
|
return `tab-${this.current}`;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 点击tab切换(核心:通过变量赋值控制滚动)
|
|
|
|
|
handleTabClick(index) {
|
|
|
|
|
|