zoukankan      html  css  js  c++  java
  • vue.js基础__component 继承

    component 继承就是父子组件的关系,在构造器外部写局部注册组件;

    如果把局部组件的编写放到构造器内部,若组件代码量很大,会影响构造器的可读性,造成拖拉和错误;

    所以要把组件填写的代码放到构造器外部或者说成单独组件;

    应先声明一个对象,对象里就是组件的内容,代码示例如下:

    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>componen-3 继承</title>
    <script src="../assets/js/vue.js"></script>
    </head>

    <body>
    <h1>componen-3 继承</h1>
    <hr>
    <div id="app">
    <province></province>
    </div>
    <script>

    var city={
    template: `<div style="color:green;">word</div>`
    }
     
    var provinceComplate = {
    template: `
    <div style="color:red;">
    hello
    <city></city>
    </div>
    `,
    components:{
    'city':city
    }
    }

    var app = new Vue({
    el: '#app',
    components: {
    'province': provinceComplate
    }
    })
    </script>
    </body>

    </html>
  • 相关阅读:
    三、checkedListBoxControl
    三、安装MyCat-Web
    三、zookeeper安装
    二、.Net 连接mycat
    一、MyCat的搭建
    二、优惠卷
    二、Docker部署应用
    【2019-05-08】感知当下
    【一句日历】2019年7月
    【读书】2019
  • 原文地址:https://www.cnblogs.com/sunyang-001/p/11101192.html
Copyright © 2011-2022 走看看