vue酷狗音乐实战开发— 2.vuex的使用
发布日期:2021-05-06 19:38:20 浏览次数:20 分类:技术文章

本文共 1133 字,大约阅读时间需要 3 分钟。

总结一下上节的路由

接口测试

设置代理

proxyTable: {    "/proxy/": { // 以 /proxy/为开头的适合这个规则        target: "http://m.kugou.com", // 目标地址            "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.com/plist/class    访问地址:http://localhost:8080/api/plist/class 访问第三方接口为:    http://m.kugou.com/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

上一篇:vuex—1vuex初始
下一篇:vue酷狗音乐实战开发—1-酷狗音乐的需求,路由设计和mint-ui安装

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年03月28日 12时52分32秒