<!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>