🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` <!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>Document</title> <script src="https://cdn.bootcss.com/vue/2.5.18-beta.0/vue.js"></script> </head> <body> <div id="app"> {{sum}} </div> <script> new Vue({ el:"#app", data:{ num1:10, num2:20, num3:30 }, computed:{ sum(){ return this.num1 + this.num2 } }, // sum值发生改变触发 updated() { console.log(this.sum) }, }) </script> </body> </html> ```