mvvm计算器实现

Original 2019-02-20 20:34:56 372
abstract:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>vue.js</title> <style type="text/css"> </style> <script type="tex

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>vue.js</title>

<style type="text/css">


</style>

<script type="text/javascript" src="Vue.js"></script>

</head>

<body>

<div id="addminus">

<input type="text" v-model="oneNum" />

<input type="text" v-model="twoNum" />{{countNum}}

</div>

</body>

</html>

<script type="text/javascript">

var addMinus = new Vue({         

el:'#addminus',

data:{   

      oneNum:'23',  //定义默认值

      twoNum:'45'          

      },

      computed:{    

      countNum:function(){  

      return Number(this.oneNum) + Number(this.twoNum)//定义方法两数相加

      }}

       });


</script>

KQFSJCH0VMZDIZEI37@09(T.png

Correcting teacher:韦小宝Correction time:2019-02-21 09:06:44
Teacher's summary:写的很不错 掌握了侦听器可以在好多地方都可以使用到 并且还提高了方便度

Release Notes

Popular Entries