vue 基础入门笔记 05:v-for、v-if

vue 基础入门笔记 05

  1. v-if 每次都要删除元素或创建元素
  2. v-show 每次display:none 或者 block

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    </head>
    <body>
    <div id="app">
        <button @click="show = !show ">按钮</button>
        <!-- v-if 每次都要删除元素或创建元素 -->
        <p v-if='show'>show</p>
        <!-- 每次display:none 或者 block -->
    
        <p v-show='show'>show</p>
    </div>
    <script>
        var vm=new Vue({
           el:'#app',
           data:{
               show:true
           },
           methods:{}
        });
    </script>
    </body>
    </html>
本作品采用《CC 协议》,转载必须注明作者和本文链接
日照香炉生紫烟
September
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!