Register a global components
< Div ID = "App" > < Test > </ Test > </ div > < Script > // Register Global assembly Vue.component ( 'Test ' , { Template: ' ! <H1 of> custom components </ h1> ' }) // Create a root instance new new Vue ({ EL: ' #app ' }) </ Script >
Create a local component (only in the parent template)
<div id="app"> <test></test> </div> <script> var Child = { template: '<h1>自定义组件!</h1>' } new Vue({ el: '#app', components: { 'test': Child } }) </script>