vue.use是什么呀?


当前第2页 返回上一页

1

Vue.use(ElementUI);

我们观察到这里使用了Vue.use方法并将ElementUI这个对象传入。从Vue.use文档中可以得知,这会调用ElementUI对象的install方法,并将Vue传入。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

// install函数

const install = function(Vue, opts = {}) {

 locale.use(opts.locale);

 locale.i18n(opts.i18n);

 

// 安装组件:通过Vue.component声明全局组件,所以我们能够直接使用而不需要声明

 components.forEach(component => {

   Vue.component(component.name, component);

 });

 

 Vue.use(InfiniteScroll);

 Vue.use(Loading.directive);

 

// 在Vue的原型链上做一些小动作所以所有的Vue实例都可以访问到这些生命的变量

// 变量名使用$开头表明这是公共API属性或者方法,这是一种约定。

 Vue.prototype.$ELEMENT = {

   size: opts.size || '',

   zIndex: opts.zIndex || 2000

 };

 

// ok,这里我们看到了许多用于提示的组件都设定在Vue原型链上,所以我们可以在Vue实例内部直接使用this.$alert

 Vue.prototype.$loading = Loading.service;

 Vue.prototype.$msgbox = MessageBox;

 Vue.prototype.$alert = MessageBox.alert;

 Vue.prototype.$confirm = MessageBox.confirm;

 Vue.prototype.$prompt = MessageBox.prompt;

 Vue.prototype.$notify = Notification;

 Vue.prototype.$message = Message;

 

};

更多编程相关知识,请访问:编程视频!!

以上就是vue.use是什么呀?的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

vue.js能做轮播图吗

vue+iview框架实现左侧动态菜单功能的示例

如何理解vue中的全局组件和局部组件

click在vue里怎么实现

vue和react属于js库吗

vue+axios+php如何实现上传文件功能?

Vue.use中发生了什么

如何解决vue 引入字体css报错问题

vuex中mutations怎么理解?怎么用?

在vue中destroy是什么意思?

更多相关阅读请进入《Vue.use》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...