007——VUE中非常使用的计算属性computed实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非常使用的计算属性computed实例:</title>
    <script src="vue.js"></script>
</head>
<body>
<div id="hdcms">
    <input type="text" v-model="n1">+
    <input type="text" v-model="n2">=
    <input type="text" v-model="sum">

</div>
<script>
    var app = new Vue({
        el: "#hdcms",
        computed:{
            sum:function () {
                return this.n1*1+this.n2*1;
            }
        },
        data:{
            n1:0,
            n2:1
        }
    });
</script>

</body>
</html>

  

原文地址:https://www.cnblogs.com/yiweiyihang/p/8059601.html