How to use global variables in vue
Sep 19, 2017 am 10:11 AMvue uses global variables
When you use components in vue to make requests, you inevitably need to set the baseURL. But it is best not to write this baseURL in a global vue component. If it is written into a component, you will find that it is encrypted if you modify it after packaging.
Okay, here is a way to introduce global variables.
1. Create a new js file:
##File content As follows:
const BASE_URL = 'http://192.168.0.108:7878/zkview/' export default { BASE_URL }
import global_ from './../static/config/global'
Vue.prototype.GLOBAL = global_; axios.defaults.baseURL = global_.BASE_URL;
alert(this.GLOBAL.BASE_URL);
The above is the detailed content of How to use global variables in vue. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What software is crystaldiskmark? -How to use crystaldiskmark?

How to download foobar2000? -How to use foobar2000

How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection'
