zoukankan      html  css  js  c++  java
  • $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)
          }    


     

  • 相关阅读:
    新手Cocoa&Objectivec的进阶
    设计模式六大原则
    仿IOS Launch 欢迎界面
    新手开发IOS的疑惑,待补充
    Windows xp系统Hal.dll文件损坏的解决办法
    上班五年了!总结一下收获篇
    关于理财:摘自“华夏基金网”
    《雪》
    上班五年了!总结一下性格篇
    索尼爱立信M608C使用心得!
  • 原文地址:https://www.cnblogs.com/3sss-ss-s/p/10177036.html
Copyright © 2011-2022 走看看