zoukankan      html  css  js  c++  java
  • Vue学习笔记

    vue 局部注册的调用

    在官方文档是这样描述的:不需要全局注册每个组件。可以让组件只能用在其它组件内,用实例选项 components 注册

    var Child = Vue.extend({ /* ... */ })
    
    var Parent = Vue.extend({
      template: '...',
      components: {
        // <my-component> 只能用在父组件模板内
        'my-component': Child
      }
    })

    那么问题来了,小伙伴如何调用,请看下面示例:

       var Child = Vue.extend({
                template: "Child boy"
            })
            var Parent = Vue.extend({
                template: 'This is Parent and has <my-component></my-component>',
                components: {
                    // <my-component> 只能用在父组件模板内
                    'my-component': Child
                }
            })
            Vue.component('p-component', Parent);

    页面调用:

      <p-component></p-component>

    结果:This is Parent and has Child boy

  • 相关阅读:
    学习进度表 06
    课堂练习第七周
    学习进度表 05
    学习进度表 04
    分组情况
    求子数组最大值
    codeforce 8A-8C
    nginx 设置服务,开机启动
    转 ubuntu 安装php
    Nginx小记
  • 原文地址:https://www.cnblogs.com/xianglx/p/5680663.html
Copyright © 2011-2022 走看看