zoukankan      html  css  js  c++  java
  • 4.vue class 绑定- model基础应用

     
      //代码可以复制自行体验
     
    <template>
     
      <div id="app" @click.stop="test('你点击了我big-div')">
           <P :class="{test:isElseTrue}">hahaha</P>
           <p :class="class1">hjaasdasd</p>                        
           <p :style="styleclass">hahahaha</p>
           <p @click.stop="test('你惦记了我')">b:hahahaha</p>

           <input @keyup.65="test('你按下了a')"><br/>
           <input type="checkbox" id="bask" v-model="boolvalue="篮球">
           <label for="bask">篮球</label> 
            <input type="checkbox" id="foot" v-model="boolvalue="足球">
           <label for="foot">足球</label> 
            <input type="checkbox" id="ym" v-model="boolvalue="羽毛球">
           <label for="ym">羽毛球</label> 
           <p>{{bool}}</p>


            <input type="radio" id="man" v-model="sexvalue="男">
             <label for="man"></label> 
                  <input type="radio" id="nv" v-model="sexvalue="女">
             <label for="nv"></label> 
              <p>{{sex}}</p>
              <select name="" id="" v-model="sel">
                <option value="杭州">杭州</option>
                 <option value="北京">北京</option>
              </select><br/>
     
              <select name="" id="" v-model="sel">
                 <option v-for='(city,indexin arr' :key='index' :value='city'>{{city}}</option>
              </select>
              <p>{{sel}}</p>
     
               <input type="text" v-model.lazy="sel">
               <p>{{sel}}</p>
     
               <input type="text" v-model.number="num1">+    //转为数值
               <input type="text" v-model.number="num2">=
              <input type="text" :value="num1+num2"/><br/>
               <input type="text" v-model.trim.lazy="sex">
               <p>{{sex}}</p>
     </div>
    </template>

    <script>
    export default {
      name: 'App',
      data () {
              return { 
                  sex:[],
                  arr: ['北京','杭州','上海','深圳'],
                  num1:0,
                  num2:0,
                  bool:[],
                  isture: false,
                  isElseTrue:true,
                  styleclass:{
                    color: "#155",
                    backgroundColor:"#f0f"
                  },
                  sel:[]
              }
      },
      methods: {          //Imethod中写的是对事件处理的处理函数
        test:function (aa) {
          console.log(aa)
        }
      },
      computed: {
        class1: function () {
          return {
            test : true
          }
        },
       
      }
    }

    </script>

    <style>
    #app {
      font-family'Avenir'HelveticaArialsans-serif;
      -webkit-font-smoothingantialiased;
      -moz-osx-font-smoothinggrayscale;
      text-aligncenter;
      color#2c3e50;
      margin-top60px;
    }
    .test{
      color:skyblue;
    }
    </style>
  • 相关阅读:
    能飞英语学习软件学习实践
    英语学习方式总结与实践
    Hello World
    centos 7.6中搭建samba共享服务
    PHP漏洞全解(一)PHP网站的安全性问题
    MySQL查询语句练习题
    在PHP中使用CURL实现GET和POST请求的方法
    js数组的操作大全
    php四种基础算法:冒泡,选择,插入和快速排序法
    Linux查看端口使用状态及启动
  • 原文地址:https://www.cnblogs.com/taozhibin/p/13065197.html
Copyright © 2011-2022 走看看