Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vue-cli3.0.x

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you about how to use vue-cli3.0.x. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Installation environment

Here, npm install-g @ vue/cli is recommended. Other settings need to be made through yarn global add @ vue/cli, and some files are generated and deleted for a few minutes.

Npm install-g @ vue/cli# oryarn global add @ vue/cli# uses the vue command to create a project (different from cli2.0 's init,create) vue create my-project

If you use yarn global add @ vue/cli to install, you need to go to the directory. Execution

The yarn / / installation project relies on cd packages/@vue/cli / / directory yarn link / / add link `vue` to perform instructions. Vue create my-project / / create a project.

Multi-environment configuration

Because the company has development environment, test environment, joint debugging environment, online environment. Reduce artificial configuration, one-time configuration to the principle. So in 2.0.x added "package.json" tt ":" node build/tt-build.js "" type configuration, configuration can not be a lot of files. The ".env" file configuration is supported in vue-cli 3.0.x, and I add ".env.development", ".env.production" and ".env.test" configurations here.

1. Basic correspondence and default

Development is used by vue-cli-service serve production is used by vue-cli-service build test is used by vue-cli-service test

two。 Specify configuration startup

To add other configurations, you need to specify the configuration below.

"dev-build": "vue-cli-service build-mode development"

3. Compilation of ".env" configuration file

The content of the configuration file is in the following format

VUE_APP_*

For example, ".env.production" is as follows

VUE_APP_MOCK_URL = 'https://xxx.xxx.xxx/restapi/'

4. Adjust the configuration of the environment

Console.log (process.env.VUE_APP_MOCK_URL); process.env.NODE_ENV / / specific BASE_URL / / vue.config.js configuration Thank you for reading! This is the end of the article on "how to use vue-cli3.0.x". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report