Vue登录

Vue中路由携带参数跳转:

<router-link :to="{'name':'coursedetail','params':{'id':course.id}}">课程详情</router-link>

在跳转路由中取值:course_id:this.$route.params.id,

v-modal="name" 数据的双向绑定

Vue中将数据放入cookie中

安装 npm install vue-cookies

使用:

导入: import Cookies from 'vue-cookies'

写cookie: Cookies.set('name',response.name,5)(过期时间单位为秒)

取cookie: Cookies.get('name')

vuex的使用:

在store.js中

state:{name:Cookies.get('name'),

token:Cookies.get('token'),},

mutations:{

login:function(state,response){state.name=response.name

state.token=response.token

Cookies.set('name',response.name,5)(参数单位为秒)

Cookies.set('token',response.token,5)},

logout:function(state){

state.name=""

state.token=""

Cookies.set('name',"")

Cookies.set('token',"")}}

使用方法:(调用)

this.$store.commit('方法名','canshu')

修改值:

this.$store.state.name = ''

this.$store.state.token='ewqr'

 

转载于:https://www.cnblogs.com/suncunxu/p/10671693.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值