Vue 两数相加

原创2019-08-06 15:15:4648
摘要:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&

<!DOCTYPE html>

<html lang="en">


<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>两数相加</title>

</head>


<body>

<div id="box">

<input type="text" v-model="ip1" />+

<input type="text" v-model="ip2" /><br>

<h3>{{zong}}</h3>

</div>


</body>

<script src="./js/vue.js"></script>

<script>

new Vue({

el: '#box',

data: {

ip1: '0',

ip2: '0',

},

computed:{

zong:function(){

return Number(this.ip1) + Number(this.ip2)

}

}

});

</script>


</html>


批改老师:Peter-Zhu批改时间:2019-08-07 13:26:14
老师总结:通过这个小案例, 可以体会到Vue对常用操作的简化

发布手记

热门词条

第九期线上培训班