3.父元件和子元件
阿新 • • 發佈:2020-12-29
<body> <div id="app"> <cpn2></cpn2> </div> <script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js'></script> <script> const cpnC1 = Vue.extend({ template: ` <div> <h5>我是標題</h5> <p>我是一個段落我是一個段落</p> </div> ` }); const cpnC2= Vue.extend({ template: ` <div> <h1>恭喜發財</h1> <p>紅包拿來 萬事如意</p> <p>lalallalalallala</p> <cpn1></cpn1> </div> `, components: { cpn1: cpnC1, } }) const app= new Vue({ el: '#app', data: { }, components: { cpn2: cpnC2, } }) </script> </body>