1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <!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-com name="zhangsan" age="18">
- <ul>
- <li>1</li>
- <li>2</li>
- <li>3</li>
- </ul>
- </my-com>
- <my-coms></my-coms>
- </div>
- <div id="app1">
- <my-com></my-com>
- </div>
- <template id="temp1">
- <div>
- <p>{{name}}</p>
- 1111
- <p>{{age}}</p>
- <slot></slot>
- <h2>我是temp1</h2>
- <h2>我是模板</h2>
- </div>
- </template>
- <script src="./vue.js"></script>
- <script>
- //template 模板里面 要有一个最底层的div去嵌套
- Vue.component('my-coms', {
- template: '<h2>hahahahhaha</h2>'
- })
- new Vue({
- el: "#app",
- data: {
- msg: 1
- },
- components: {
- 'my-com': {
- template: '#temp1',
- props: ['name', 'age']
- }
- }
- })
- new Vue({
- el: '#app1'
- })
- </script>
- </body>
- </html>
|