![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Vue
Funny chen
这个作者很懒,什么都没留下…
展开
-
Vue router根据设备型号,显示对应路由
import Vue from 'vue'import Router from 'vue-router'Vue.use(Router)var routes = [];//pc端路由const WebRoutes = [];//移动端路由const mobileRoutes = [];//核心判断if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|I原创 2022-03-10 13:32:03 · 836 阅读 · 0 评论 -
vue项目中axios拦截器统一管理接口请求
1. 拦截器配置新建request.js文件import axios from "axios";import qs from "qs";const service = axios.create({ baseURL: 'http://120.77.11.179:3000', //接口域名 timeout: 5000, // 请求超时时间});//请求service.interceptors.request.use((config) => { return config;原创 2022-03-10 13:22:57 · 502 阅读 · 0 评论 -
Vue实现增删改视图局部刷新(provide,inject)
App.vue<template> <div id="app"> <router-view v-if="isRouterAlive" /> </div></template><script>export default { name: 'App', provide() { return { reload: this.reload } }, data() { .原创 2021-09-22 17:18:38 · 131 阅读 · 0 评论 -
Vue路由守卫实现无登录只跳转到登录页面
在实际的项目中,有一些页面是需要登录后才可以浏览,有一些功能需要登录权限。如果没限制用户未登录也可以通过url直接浏览,这需要我们路由上做一些限制。在登录成功后,后端会返回一个唯一token,我们可以把这个token通过localStorage存起来localStorage.setItem('token', token);在router/index.js下router.beforeEach((to, from, next) => { let token = localStorage.g原创 2021-09-22 17:12:33 · 1615 阅读 · 0 评论