说明

v-show和v-if的用法看起来是一致的,也是根据一个条件决定是否显示元素或者组件
image.png

  1. <template>
  2. <div id="app">
  3. <button>1</button>
  4. <button>2</button>
  5. <button v-show="isDisplay">3</button>
  6. <div class="change" @click="show">改变</div>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. isDisplay: false
  14. };
  15. },
  16. methods: {
  17. show() {
  18. this.isDisplay = !this.isDisplay
  19. }
  20. }
  21. };
  22. </script>

和v-show的区别

1、用法上

不支持