Home> Web Front-end> Vue.js> body text

How to define variables in vue.js

王林
Release: 2020-11-30 14:35:02
Original
6338 people have browsed it

The method of defining variables in vue.js: first define a vue module; then use const to define variables, and use export to expose them; finally, import them in the module that needs to use global variables.

How to define variables in vue.js

The operating environment of this tutorial: Windows 10 system, vue version 2.9. This method is suitable for all brands of computers.

(Related video sharing:javascript video tutorial)

The steps to define variables are as follows:

1. Define a vue module and define variables with const. And use export to expose it to the outside world.

Globle.vue

Copy after login

2. For modules that use global variables, use

test.vue

import global_ from 'components/common/Global.vue' console.log(global_.SERVER_BASE_URL)
Copy after login
## after importing. #Related recommendations:

vue.js tutorial

The above is the detailed content of How to define variables in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!