随笔分类 - Vue
摘要:一:mapState的使用 此函数返回一个对象,生成计算属性 - 当一个组件需要获取多个状态时候,将这些状态都声明为计算属性会有些重复和冗余。mapState可以声明多个 需要在组件中引入: 需要在组件中引入:import { mapState } from 'vuex' ...mapState({
阅读全文
摘要:// isLogined 用来判断用户是否已登录 router.beforeEach((to, from, next) => { if(isLogined){ next() }else{ console.log('测试') next('login') } }) next() 表示放行,直接进入to路
阅读全文