圆月山庄资源网 Design By www.vgjia.com
在vue开发中,不可避免要整合axios,简单记录一下整合中的文件,方便以后使用查找。
整合文件axios.js
import axios from 'axios'; // 适配vue-resource const instance = axios.create(); instance.interceptors.request.use(config=> { //Serialize.decode(config); return config; }); instance.interceptors.response.use(response=> { return response.data; }, err=> { if (err.response) { axios.post('/v1/error', err.response); return Promise.reject(err.response.data); } return Promise.reject({ code: 1024, message: err.message }); }); functionplugin(Vue){ if (plugin.installed) { return; } Vue.http = instance; } if (typeof window !== 'undefined' && window.Vue) { window.Vue.use(plugin); } export default plugin;
vue插件使用 app.js
import Vue from 'vue'; import App from './App.vue'; import store from './store'; import { sync } from 'vuex-router-sync'; import router from './router'; import * as filters from './filters'; import yxui from 'yxui/dist/yxui.min'; import axios from './axios'; Vue.use(yxui); Vue.use(axios); // sync the router with the vuex store. // this registers `store.state.route` sync(store, router); // register global utility filters. Object.keys(filters).forEach(key=> { Vue.filter(key, filters[key]); }); // create the app instance. // here we inject the router and store to all child components, // making them available everywhere as `this.$router` and `this.$store`. const app = new Vue({ router, store, ...App }); // expose the app, the router and the store. // note we not mounting the app here, since bootstrapping will be // different depending on whether we are in browser or on the server. export { app, router, store };
在vuex action 中使用:
actions: { // adList [TypesAds.AD_GET_LIST](ctx, params){ return Vue.http.get('/v1/api/ads/list', {params}).then(data=> { ctx.commit(TypesAds.AD_GET_LIST, data); return data; }).catch(err=> { //统一错误处理 Vue.$message.error(err.msg); }); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年10月19日
2024年10月19日
- 群星《歌手2024 第4期》[FLAC/分轨][563.76MB]
- RiffKitten-ChaosParade(2024)[24-44,1]FLAC
- RuneKlakegg-Nattevandrer(2024)[24-96]\FLAC
- 赖冰霞.2006-金嗓典藏辑2IN1(南方金点系列)2CD【南方】【WAV+CUE】
- 群星.1988-国语金曲尽精英VOL.2【瑞成】【WAV+CUE】
- 张宇.1999-雨一直下【EMI百代】【WAV+CUE】
- 袁娅维.2021-月亮失眠了(DELUXE)【华纳】【FLAC分轨】
- AlanBroadbent-JazzFunk(2024)[24-44,1]
- 梅艳芳《绝代芳华》开盘母带[低速原抓WAV+CUE]
- ABC唱片-《外国精逊母带直刻神奇黑胶[APE+CUE].
- 群星《天赐的声音第五季 第6期》[320K/MP3][101.43MB]
- 群星《天赐的声音第五季 第6期》[FLAC/分轨][526.16MB]
- 群星《说唱梦工厂 第2期》[320K/MP3][96.37MB]
- 杨宗宪.1994-留你留袂着【有容唱片】【WAV+CUE】
- 李翊君.2005-勇敢的爱【创意唱片】【WAV+CUE】