123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- <my-component></my-component>
- <my-com name="zs" age="18">
- <ul>
- <li>111</li>
- <li>222</li>
- </ul>
- <h2>xixixixi</h2>
- </my-com>
- <my-com1></my-com1>
- </div>
- <div id="temp1">
- <my-component></my-component>
- </div>
- <template id="tem1">
- <div>
- <h2>{{name}}</h2>
- <h2>{{age}}</h2>
- <!-- 插槽 -->
- <slot></slot>
-
- </div>
- </template>
- <script src="vue.js"></script>
- <script>
- Vue.component('my-component',{
- template: '<h2>哈哈哈哈哈</h2>'
- })
- new Vue({
- el:"#app",
- data:{
- },
- components:{
- 'my-com':{
- template: '#tem1',
- props:['name','age'] //接收调用该组件 父组件传过来的参数
- },
- 'my-com1':{
- template:'<h2>呵呵呵呵呵呵</h2>'
- }
-
- }
- })
- new Vue({
- el:"#temp1",
- data:{
- }
- })
- </script>
- </body>
- </html>
|