英文:
How to register the id div in the Vue button?
问题
In this line, you can specify that only the "ten" div should be displayed by modifying the code like this:
在这行代码中,您可以指定只显示“ten” div,如下所示:
v-on:click="visible=true, isHidden = false"
这将使“visible”为true,同时将“isHidden”设置为false,从而只显示“ten” div。
英文:
there is such a construction:
<div v-show="visible" id="ten"></div>
<div v-show="visible" id="twelve"></div>
<button v-if="!isHidden" v-on:click="visible=!visible,
isHidden = true">Click Me!</button>
<script>
export default {
data() {
return {
visible: false,
isHidden: false,
}
/*.....................................*/
can I specify in this line that only the "ten" div should be displayed?
v-on:click="visible=!visible, isHidden = true"
答案1
得分: 1
如果您想分别控制子元素的可见性,您需要一个单独的变量。例如:
data() {
return {
ten_isVisible: true,
twelve_isVisible: true
}
}
<div v-show="ten_isVisible" id="ten"></div>
<div v-show="twelve_isVisible" id="twelve"></div>
当然,您还需要单独的控件(按钮、复选框或其他任何喜欢的元素)来切换不同元素的可见性。
英文:
You would need a separate variable if you want to control the visibility of child elements separately. For instance:
data() {
return {
ten_isVisible: true,
twelve_isVisible: true
}
}
<div v-show="ten_isVisible" id="ten"></div>
<div v-show="twelve_isVisible" id="twelve"></div>
And of course, you would need separate controls (buttons, checkboxes, whatever you like) to toggle the visibility of the different elements.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论