【发布时间】:2021-01-19 04:15:00
【问题描述】:
我正在尝试在子组件中使用 v-if 切换 span 元素的可见性。我基本上是在尝试将@click 切换(Vuetify)与 $refs 一起使用。对代码不是很精通,但我的研究没有找到解决方案。
家长
<v-switch label="hide manufacturer" @click="$refs.childComponent.hideManf()"></v-switch>
<child-component ref="childComponent" />
components: {
childComponent
}
子组件
<span v-if="spanManf">Name to Hide</span>
data() {
return {
spanManf: true
};
},
methods: {
hideManf () {
this.spanManf = !this.spanManf;
}
【问题讨论】:
标签: vue.js components vuetify.js toggle