【发布时间】:2018-09-21 08:33:30
【问题描述】:
我有一个 nuxt js 项目,项目文件目录如下:
| -- axios实用程序 | -- index.js | -- 页面 | - 店铺 | -- 其他目录axiosUtility/index.js文件如下:
/* Create a axios instance with custom headers */
import axios from 'axios';
let myVariable = someVariable //someVariable is the result from // asynchronous
//request with axios in some web page component, how can I get
// variable?
// with vuex?
const myAxios = axios.create({
headers: {'X-My-Variable': myVariable}
});
export default myAxios;
某些网页组件从异步请求中获取结果,我想使用来自另一个 js 文件(或第三方库)的结果。异步请求的结果保存在哪里,无论路由的变化如何要求结果?
【问题讨论】:
-
将ajax返回的值保存在vue store中。
标签: javascript vue.js axios vuex nuxt.js