怎么在html文件包含一个component : learn from https://vuejs.org/v2/guide/components.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<html> <head> <title>commponent basic 001</title> </head> <body> <h1>Hello!</h1> <div id="components-demo"> <button-counter></button-counter> </div> </body> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> Vue.component('button-counter', { data: function () { return { count: 0 } }, template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>' }) new Vue({ el: '#components-demo' }) </script> </html> |
怎么引用 单独一个 .vue 文件
from
https://vuejs.org/v2/guide/components-registration.html