Vuejs load static json file
Ngày đăng:
27/10/2021
Trả lời:
0
Lượt xem:
41
I dont really like this solution but this is what Ive done: get the correct base href in there at compile time. then in the client read it back out: const baseHref = (document.getElementsByTagName('base')[0] || {}).href; export const appConfigPromise = axios.get('static/config.json', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, baseURL: baseHref }) .then((response: AxiosResponse) => { const { apiUrl } = response.data; return new Config(apiUrl); });I would really love to know how to do this properly in Vue.js. In angular it seems to work more out of the box. |