JS相关问题
一开始是静态实现的:
this.$refs.treeMenuRef1.style.display = "none";
this.$refs.treeMenuRef2.style.display = "none";
this.$refs.treeMenuRef3.style.display = "none";
this.$refs.treeMenuRef4.style.display = "none";
this.$refs.treeMenuRef5.style.display = "none";
this.$refs.treeMenuRef6.style.display = "none";
现在想实现动态,但是会报错:
Uncaught TypeError: Cannot read property 'style' of undefined
for(a=1;a<=count;a++)
{
var x='treeMenuRef'+a;
this.$refs.x.style.display = "none";
}
请问我该如何做?