How to set the root domain name by reading the configuration file for the project packaged by vue

whether a vue project can set the root domain name of the provider by reading web.config or config.json after packaging.
in this way, even if the root domain name is redeployed in the background, the front end of the root domain name does not have to be packaged again. You only need to change the configuration file to ok

.
Feb.28,2021

index.html

window.config = {
    Host: '..........'
}

main.js
window.config.Host + 

configure a global constant

in main.js

const baseUrl = 'your domain name'
then access the interface baseUrl +'/ xxx/xxx'


1 establish the root domain name of config.json, configuration under the static folder static,
2 introduce: var URL = require ('. / static/config.json') into main.js;
this file (dist/static/config.json) will be found in the static folder under the dist folder after packaging. If you want to modify the root domain name later, just modify the config.json on the server

.
Menu