Vue自定义组件
<!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="./js/vue.js"></script> </head> <body> <div id="app"> <my-component></my-component> </div> <script> Vue.component('my-component',{ template:` <div> <h1>第一个组件</h1> <h2>第二个组件</h2> </div> ` }) var m = { } var vm = new Vue({ el:"#app", data: m, methods:{ } }) </script> </body> </html>