vue :ref属性实现双层遍历选项卡功能
html代码:
{{item}}
标题:
内容 {{index}}
vue代码:
toggle(index, items, length) {
for(var i = 0; i < length; i++) {
var string = "this.$refs.tabs" + items + "[" + i + "].style.display='none'"
console.log(string)
eval(string);
}
var string = "this.$refs.tabs" + items + "[" + index + "].style.display='block'"
eval(string);
for(var k = 0; k < length; k++) {
var str = "this.$refs.tab" + items + "[" + k + "].classList.remove('tab-active')";
eval(str);
}
var str = "this.$refs.tab" + items + "[" + index + "].classList.add('tab-active')";
eval(str);
},