123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- <chenyou></chenyou>
- <my-com></my-com>
- {{show}}
- </div>
- <script src="./vue.js"></script>
- <script>
- // 全局注册组件
- Vue.component('my-com',{
- template:`
- <div>1111</div>
- `
- })
- // 定义组件 Vue.extend
- const zhenBo = Vue.extend({
- // name 组件名
- name:"zhenBo",
- // template 组件模板
- template:`
- <div>
- <h2>马琛笑得真好看</h2>
- <p>
- {{msg}}
- </p>
- </div>
- `,
- // 组件中数据
- data() {
- return {
- msg:"嘿嘿嘿"
- }
- }
- })
- // vue实例
- new Vue({
- el:"#app",
- data:{
- show:"卢勃玮也想来"
- },
- // 注册组件
- components:{
- // 标签名要小写
- chenyou: zhenBo
- }
- })
- </script>
- </body>
- </html>
|