<!DOCTYPE html> <html lang="en"> <body>{{result}}<script src="https://unpkg.com/vue@next"></script> <script> const App = { data() { return { a : 1, b : 2 } }, computed:{ result(){ return this.a + this.b; } }, methods: { }, mounted() { setTimeout(()=>{ this.a = 3; }, 2000); }, } Vue.createApp(App).mount('#app'); </script> </body> </html>
函数定义在 computed 内,模板语法 {{ result }} 不加 ()
<!DOCTYPE html> <html lang="en"> <body>{{result()}}<script src="https://unpkg.com/vue@next"></script> <script> const App = { data() { return { a : 1, b : 2 } }, methods: { result(){ return this.a + this.b; } }, mounted() { setTimeout(()=>{ this.a = 3; }, 2000); }, } Vue.createApp(App).mount('#app'); </script> </body> </html>
能看出差别吗?
|
{{comment.u_nickname}}
{{comment.u_nickname}} @ {{comment.comments_reply_uname}}
{{comment.comments_date}}
点赞 ({{comment.comments_like_count}})
  回复 ({{comment.comments_reply_count}})
|