生活随笔
收集整理的這篇文章主要介紹了
(第三篇)组件化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
組件化
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document
</title><script src="../node_modules/vue/dist/vue.js"></script>
</head>
<body><div id="app"><button v-on:click="count++">被點擊了{{count}}次
</button><counter></counter><button-counter></button-counter></div><script>Vue.component("counter",{template:`<button v-on:click="count++">被點擊了{{count}}次</button>`,data(){return{count:1}}});const buttonCounter={template:`<button v-on:click="count++">被點擊了{{count}}次~~~</button>`,data(){return{count:1}}};new Vue({el:"#app",data:{count:1},components:{'button-counter':buttonCounter}})</script></body>
</html>
總結
以上是生活随笔為你收集整理的(第三篇)组件化的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。