[Vue基础实战]computed 测试

代码参考:

<!DOCTYPE html>
<html>
<head id="head">
    <title>computed 测试</title>
</head>
<body>
    <div id="app">
        <p>computed 测试,数值平方:{{computedNum}}</p>
        <input type="text" v-model="testNum">
        <p>computed 测试,数值平方:{{computedNum}}</p>
    </div>
    <script src="https://unpkg.com/vue/dist/vue.min.js">
    </script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                testNum: 111
            },
            computed: {
                computedNum: function () {
                    var n = this.testNum;
                    return n * n;
                }

            }
        })
    </script>
</body>
</html>

 

posted @ 2020-12-16 12:05  dshow  阅读(161)  评论(0编辑  收藏  举报