zoukankan      html  css  js  c++  java
  • vue.js 监听属性的学习/ 千米、米的转换 /时、分、秒 的转换

    <!DOCTYPE html>
    <html lang="en">
    <head>
     <meta charset="UTF-8">
     <title>vue_的监听属性</title>
     <script type="text/javascript" src="./js/vue.js"></script>
     <script type="text/javascript">
     window.onload = function(){
      var app= new Vue({
       el:"#app",
       data:{
        kilometers:0,
        meters:0
       },
       //监听属性
       watch:{
        kilometers:function(val){
         this.kilometers = val;
         this.meters = val * 1000;
        },
        meters:function(val){
         this.kilometers = val / 1000;
         this.meters.val;
        }
       }

      });
          
            var app1 = new Vue({
             el:"#app1",
       data:{
        seconds:0,
        minutes:0,
        hours:0
       },
       //监听属性
       watch:{
        seconds:function(val){
         this.seconds = val;
         this.minutes = val/60;
         this.hours=val/3600;
        },
        minutes:function(val){
         this.seconds = val*60;
         this.minutes =val;
         this.hours = val/60;
        },
        hours: function(val){
         this.seconds = val*3600;
         this.minutes = val *60;
         this.hours= val;
        }
       }
      });  
     }
     
     </script> 
    </head>
    <body>
     <div id='app'>
      千米:<input  type="text" v-model = "kilometers"/>
      米: <input type="text" v-model = "meters"/>
     </div>
     <br/> <br/>
     <div id='app1'>
     时:<input type="text" v-model = "hours">
     分:<input type="text" v-model ="minutes">
     秒:<input type="text" v-model ="seconds">
     </div>
     
    </body>
    </html>
  • 相关阅读:
    C++ STL之vector详解
    Two Sum
    The Skyline Problem
    C++ 排序函数 sort(),qsort()的用法
    GO语言为结构体排序
    php将数组或字符串写入文件
    [Zabbix] 怎样实现邮件报警通知以及免费短信报警通知
    js 图片轮转
    ios学习之旅------玩转结构体
    You have ettempted to queue to many files.You may select one files.
  • 原文地址:https://www.cnblogs.com/liang715200/p/10077374.html
Copyright © 2011-2022 走看看