vue06

作者: 小可_34e0 | 来源:发表于2021-05-10 10:47 被阅读0次

    用户登录案例:

    <body>
    <div id="app">
      <span v-if="isUser">
        <label for="username">用户账户</label>
        <input type="text" id="username" placeholder="用户账号">
      </span>
      <span v-else>
        <label for="email">用户邮箱</label>
        <input type="text" id="email" placeholder="用户邮箱">
      </span>
      <button @click="isUser=!isUser">切换类型</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
      const app=new Vue({
        el:'#app',
        data:{
          isUser:true
        }
      })
    </script>
    </body>
    

    使用v-if和v-show的区别
    v-if:当条件为false时,包含v-if指令的元素,根本不会存在在DOM中
    v-show:当条件为false时,v-show只是给我们的元素添加 了一个display:none
    当切换频率比较高时用v-show,当切换只一次或极少数时用v-if

    v-for遍历数组:


    图1

    v-for遍历对象:


    图2
    splice的应用:
    图3

    添加key属性

    图4

    哪些数组的方法是响应式的


    图5
    图6

    5是排序,6是反转

    相关文章

      网友评论

          本文标题:vue06

          本文链接:https://www.haomeiwen.com/subject/utgedltx.html