合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# 计时器案例 即对上面的组件中data的数据必须是一个函数,并且返回一个对象。 ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>05组件私有化数据</title> </head> <body> <div id="app"> {{msg}} <btn></btn> <btn></btn> <btn></btn> </div> <script src="js/vue.js"></script> <script> Vue.component('btn',{ data(){ return { num:0 } }, template:`<button @click="add()">{{num}}</button>`, methods:{ add(){ this.num++; } } }) var vue = new Vue({ el:'#app', data:{ msg:1 } }) </script> </body> </html> ```