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'