vue项目外配置

public 中新建 config.json,里面可配置项目名称等

main.js 中修改以下代码:

import axios from 'axios'
//引入配置文件
axios.get('config.json')
    .then(response => {
        Vue.prototype.baseConfig = response.data;
        new Vue({
            router,
            store,
            render: h => h(App)
        }).$mount('#app');
    })
    .catch((error) => {
        console.error(error)
    });

你可能感兴趣的:(vue项目外配置)