$Django 路飞之课程下的分类,用户登陆成功前端存cookie,
一 课程分类显示
宗旨:总的再次过滤
二 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)
}
随机推荐
- VS2015快捷键大全
Ctrl+E,D —-格式化全部代码 Ctrl+E,F —-格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O 打开文件 CTRL + SH ...
- 转载--关于hdfs
原文章链接 你肯定听过Hadoop,对就是那头奔跑的小象. 图片描述 Hadoop作为大数据时代代表性的解决方案被大家所熟知,它主要包含两部分内容: HDFS分布式文件存储 MapReduce分布式计 ...
- python 精华梳理(已理解并手写)--全是干货--已结
基础部分 map,reduce,filter,sort,推导式,匿名函数lambda , 协程,异步io,上下文管理 自定义字符串转数字方法一不使用reduce import re def str2i ...
- tomcat优化之安装并配置apr库
在谈到tomcat优化时,必然要说到apr库,这个库是C语言实现的,tomcat通过JNI方式使用该库可以大大提高性能. tomcat在使用apr时需要安装apr,apr-util和tomcat-na ...
- Spring boot 工具类静态属性注入及多环境配置
由于需要访问MongoDB,但是本地开发环境不能直接连接MongoDB,需要通过SecureCRT使用127.0.0.2本地IP代理.但是程序部署到线上生产环境后,是可以直接访问MongoDB的,因此 ...
- 关于PHP建立数据库访问类的封装以及操作php单例模式连接数据库封装类
建立数据库访问类的封装 <?php class DBDA { public $host = "localhost"; //服务器地址 public $ui ...
- c语言 弹弹球小游戏
#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <time.h>#i ...
- 迅为开发板4412开发板-ANROID系统的烧写方法分享
详情了解: http://topeetboard.com 更多了解:https://arm-board.taobao.com 一.OTG接口烧写方式 通过该方式可以烧写 Android4.0.3 ...
- ES5新增内容
一.数组API实际开发中forEach和map会多一些=>是es6语法中的arrow function举例:(x) => x + 6相当于function(x){return x + 6; ...
- python---issubclass/type/isinstance/ 反射(内置函数getattr/delattr...)
# 一 python面向对象-内置函数(issubclass(), type(), isinstance()) # issubclass 判断xxxx类是否是xxxx类的子类 class egg: p ...