项目一些配置存储在数据库,前端
前端项目初始化时须要同步先获取基本配置,而后才能渲染其它组件。ios
http请求采用axios,可是axios不支持同步请求。数据库
解决方案:axios
在获取配置接口采用async await app
async function initConfig(){
let url='htttp://123.com/getConfig';
let params={
"token": 'erwerwerewrwer'
};
await axios.post(url,params).then((data)=>{})
}async
而后 接口返回消息以后再初始化Vuepost
initConfig().then(()=>{
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
})