vue v-show指令

demo:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue入门</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
  <div id="first">
       <div v-show="show">看到啦</div>
       <button @click="handleclick">按钮</button>
  </div>
  <script>
      new  Vue({
        el:"#first",
        data:{
           show:true
        },
        methods:{
          handleclick:function(){
            this.show=!this.show;

          }
        }
      })
  </script>
</body>
</html>

  效果:

2018-05-02  00:04:15

猜你喜欢

转载自www.cnblogs.com/guangzhou11/p/8978178.html