如何在Vue按钮中注册id div?

huangapple go评论60阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年1月3日 22:53:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定