admin管理员组文章数量:1650882
总结一下上节的路由
接口测试
设置代理
proxyTable: {
"/proxy/": { // 以 /proxy/为开头的适合这个规则
target: "http://m.kugou", // 目标地址
"secure": false, // false为http访问,true为https访问
"changeOrigin": true, // 跨域访问设置
"pathRewrite": { // 路径改写规则
"^/proxy": "" // 以 /proxy/为开头改写为 ''
"^/api": "/list" // 以 /api/为开头改写为 '/list'
},
"headers": { // 设置请求头,伪装成手机端访问
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)
AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 65.0.3325.181 Mobile
Safari / 537.36"
}
}
路径改写规则:
访问地址:http://localhost:8080/proxy/plist/class 访问第三方接口为:
http://m.kugou/plist/class
访问地址:http://localhost:8080/api/plist/class 访问第三方接口为:
http://m.kugou/list/plist/class
安装vuex
npm i vuex --save
在src目录下新建 store/index.js
import Vue from 'Vue'
import Vuex from 'vuex'
Vue.use(Vuex);
let store = new Vuex.Store({
state: {
isLoading: true
},
mutations: {
updateIsLoading(state, loading) {
state.isLoading = loading;
}
}
})
export default store;
store
版权声明:本文标题:vue酷狗音乐实战开发— 2.vuex的使用 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729548996a1205990.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论