<body><divid="app"><h2>总价格:{{totalPrice}}</h2></div><scriptsrc="../js/vue.js"></script><script>const app =newVue({
el:'#app',
data:{
message:'你好呀',
books:[{id:101,name:'Unix编程大全',price:79},{id:102,name:'代码大全',price:96},{id:103,name:'深入理解计算机原理',price:99},{id:104,name:'现代操作系统',price:88},]},
computed:{totalPrice:function(){let result =0for(let i =0;i<this.books.length;i++){
result +=this.books[i].price
}return result
}}})</script></body>