vue项目外配置

2020-11-08  本文已影响0人  酪蕊璺

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)
    });
上一篇 下一篇

猜你喜欢

热点阅读