Vue vue.extend 和vue.component 两则之间的区别
Vue.extend 返回的是一个 扩展实例构造器, 也就是一个预设了部分选项的Vue实例构造器
Var myExtend = Vue.extend({
//预设选项
})//返回一个 扩展实例构造器
//然后就可以这样来使用
var vE = new myExtend({
//其它选项
})
Vue.component 是用来全局注册组件的方法,其作用是将通过 Vue.extend 生成的扩展实例构造器注册(命名)为一个组件,可以简单理解为当在模板中遇到该组件名称作为标签的自定义元素时,会自动调用类似于 new myVue 这样的构造函数来生成组件实例,并挂载到自定义元素上,当然实际情况要比这复杂得多,还需要处理 props 数据传递、slot 内容分发、自定义事件、组件生命周期……事宜。
html:
<vE></vE>
此时页面必然是没有任何效果的,:
扩展实例构造器还需要挂载:
new eE().$mount('eE');
https://www.jb51.net/article/118851.htm
extend 是构造一个组件的语法器。
你给它参数 他给你一个组件 然后这个组件可以用到Vue.component 这个全局注册方法里,
也可以在任意vue模板里使用<componentname>组件
var apple = vue.extend({
...
})
Vue.component('componentname',componentname‘)
你可以用到vue实例或者某个组件中的components 属性中并在内容使用template-name
new Vue({
components:{
componentname:comontentname
}
})
Vue.component你可以创建,也可以取组件
Sample:
var component = Vue.component('componentname')
Vue vue.extend 和vue.component 两则之间的区别的更多相关文章
- vue.extend和vue.component的区别
vue.extend 使用基础 Vue 构造器函数,通过原型继承,(返回)创建一个"子类"(构造器).参数是一个包含组件选项的对象. const Sub = function Vu ...
- Vue.extend和Vue.component的联系与差异
extend 是构造一个组件的语法器. 你给它参数 他给你一个组件 然后这个组件 你可以作用到Vue.component 这个全局注册方法里, 也可以在任意vue模板里使用apple组件 var ap ...
- vue中extend/component/mixins/extends的区别
vue中extend/component/mixins/extends的区别 教你写一个vue toast弹窗组件 Vue.extend构造器的延伸
- 前端框架vue.js系列(9):Vue.extend、Vue.component与new Vue
前端框架vue.js系列(9):Vue.extend.Vue.component与new Vue 本文链接:https://blog.csdn.net/zeping891103/article/det ...
- Vue与REACT两个框架的区别和优势对比
VUE和REACT两个JavaScript框架都是当下比较受欢迎的,他们两者之间的区别有那些,各自的优缺点是什么,本文将为你呈现. 简单介绍 除非你最近一直不关注前端的发展,不然你肯定听说过由Face ...
- Vue报错之"[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead......"
一.报错截图 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the p ...
- Vue与React两个框架的区别对比
简单介绍 React--Facebook创建的JavaScript UI框架.它支撑着包括Instagram在内的大多数Facebook网站.React与当时流行的jQuery,Backbone.js ...
- vue通过extend动态创建全局组件(插件)学习小记
测试环境:nodejs+webpack,例子是看文章的,注释为自己的理解 创建一个toast.vue文件: <template> <div class="wrap" ...
- "[Vue warn]: Failed to mount component: template or render function not defined"错误的解决
VUE中动态路由出错: vue.esm.js?a026: [Vue warn]: Failed to mount component: template or render function not ...
随机推荐
- C++随记
1.const限定符 const限定变量的值不可变,并且const对象必须要初始化 const int buf = 512; //正确,表明buf的值为512 buf = 400; //错误,buf ...
- 国内Maven仓库 - 2018年5月2日15:54:10
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- proxool连接sqlerver
原先proxool连接sqlserver,用的是sqljdbc,不知道怎么回事,怎么也连接不上.下面的代码既不报错也不执行下去,应该是驱动出了问题,网上也很难找到sqljdbc什么版本. if (_c ...
- java axis2 webservice
http://clq9761.iteye.com/blog/976029/ 这篇文章写的是最全的,也是最好的.无须下一步下一步操作来操作去,写类直接调试,非常好!
- C# 图像处理:获取鼠标位置信息(全局)
Point ms = Control.MousePosition; //获取鼠标位置 this.label2.Text = string.Format("{0}:{1}", ms. ...
- Conscription-最小生成树-Kruskal
Windy has a country, and he wants to build an army to protect his country. He has picked up N girls ...
- php mysql 查询判断周几
$where .= " and (DAYOFWEEK( from_unixtime(`px_time`, '%Y-%m-%d')) = 1)"; //周日从1开始
- ubuntu下zaibbix3.2报警搭建
1.安装sudo apt install sendmail 2.测试发送邮件: echo "正文!" | mail -s 标题 XXX@qq.com 3.成功后继续安装邮件服务器. ...
- Centos6.5 防火墙设置详解
vim /etc/sysconfig/iptables #丢弃所有进入请求 INPUT DROP [0:0] #丢弃所有转发请求 FORWARD DROP [0:0] #允许所有的output请求 O ...
- Animator
[Animator] 1.State Machine Behaviours A State Machine Behaviour is a special class of script. In a s ...