使用vue.js怎么定义全局变量


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

// The Vue build version to load with the `import` command

// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

import Vue from 'vue'

import App from './App'

import router from './router'

import fastclick from 'fastclick'

import global_ from './components/Global.vue'  //引入全局组件

Vue.prototype.GLOBAL = global_;  //修改原型

Vue.config.productionTip = false

/* eslint-disable no-new */

new Vue({

  el: '#app'

  router,

  components: { App },

  template: '<App/>'

})

步骤三、使用

在需要 的vue页面直接使用 this.GLOBAL.BASE_URL,就可以获取到定义常量值

相关免费学习推荐:javascript(视频)

以上就是使用vue.js怎么定义全局变量的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

vue.js支持jquery吗?

怎么使用npm下载vue.js

vue 的 render 方法中 h 是什么?

vue.js怎么样显示时间

vue.js中怎么移除数组值

vue.js能做pc端吗

vue.js怎么用jq

什么叫vue.js

vue.js怎么用swiper

vue.js如何上传文件

更多相关阅读请进入《vue.js》频道 >>




打赏

取消

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

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

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

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

评论

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