组件模板抽离
<body> <div id="app"> <my-component></my-component> </div> <template id="zujian"> <div> <p>我是内容</p> </div> </template> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> Vue.component('my-component',{ template:'#zujian' }); new Vue({ el:'#app', data:{ message:'hello world' } }) </script> </body>