一 课程分类显示

宗旨:总的再次过滤

二 Cookie

#
export default new Vuex.Store({
state: {
name:'',
token:'',
},
mutations: {},
actions: {}
})
#全局数据
#赋值
methods:{
upup:function () {
let _this=this
this.$http.request({
url:'http://127.0.0.1:8000/login/',
method:'post',
data:{
name:_this.name,
pwd:_this.pwd
}
}).then(function (response) {
_this.$store.state.name=response.data.name
_this.$store.state.token=response.data.token
})
},
}
#取值
<span class="pull-right" v-if="!this.$store.state.token">

Vuex状态管理器stoer介绍

vue-cookies
-安装:npm install vue-cookies
-使用:
-store.js中导入import Cookie from 'vue-cookies'
-取值:Cookie.get('根据key值')
-赋值:Cookie.set('key值','value值')
定义方法
export default new Vuex.Store({
state: {
name:Cookie.get('name'),
token:Cookie.get('token'),
},
mutations: {
//设置cookie
set_state:function (state,response) {
state.name=response.name
state.token=response.token
Cookie.set('name',response.name)
Cookie.set('token',response.token)
},
//注销,清除所有数据(cookie,store中的数据)
clear_state:function (state) {
state.name=''
state.token=''
Cookie.set('name','')
Cookie.set('token','')
}
},
actions: {}
})
调用方法
if (response.data.status==100){
_this.$store.commit('set_state',response.data)
}

随机推荐

  1. sc (service control )

    SC 是用来与服务控制管理器和服务进行通信 net: net start 服务名 net stop 服务名 sc: sc config 服务名 start= demand    //手动 sc con ...

  2. THE DEFINITIVE GUIDE TO DEBUGGING JAVASCRIPT

    FIGURING OUT WHERE THE ERROR COULD BE READ THE CODE USING THE CONSOLE THE CHROME DEV TOOLS THE DEBUG ...

  3. redis基本操作

    ''' pip install redis redis 可以看成内存中的大字典 redis五大数据类型 --> 指的是第一层的value值的类型 - 字符串 "k1" - 列 ...

  4. 记录MySQL的一些基础操作

    MySQL建表操作 root@localhost 08:05:22> create table stu( -> id int(4) not null, -> name char(20 ...

  5. 关于CPU的User、Nice、System、Wait、Idle各个参数的解释

    使用Ganglia监控整个Hadoop集群,看到Ganglia采集的各种指标:CPU各个具体的指标含义解释如下: ①CPU(监测到的master主机上的CPU使用情况) 从图中看出,一共有五个关于CP ...

  6. [Windows] [VS] [C] [取得指针所指内存的二进制形式字符]

    // 取得指针所指内存的十六进制形式字符串,size指定字节长度#define Mem_toString(address, size) _Mem_toString((PBYTE)address, si ...

  7. spring注解第05课 FactoryBean

    1.工厂bean调用 @Configuration public class MainConfig2 {/** * 使用Spring提供的 FactoryBean(工厂Bean); * 1).默认获取 ...

  8. Groovy 设计模式 -- null对象模式

    Null Object Pattern http://groovy-lang.org/design-patterns.html#_loan_my_resource_pattern 对于一些场景获得的对 ...

  9. luogu 4377 Talent show 01分数规划+背包dp

    01分数规划+背包dp 将分式下面的部分向右边挪过去,通过二分答案验证, 注意二分答案中如果验证的mid是int那么l=mid+1,r=mid-1,double类型中r=mid,l=mid; 背包dp ...

  10. deque

    转自:https://www.cnblogs.com/LearningTheLoad/p/7450948.html deque双向开口可进可出的容器 我们知道连续内存的容器不能随意扩充,因为这样容易扩 ...