zoukankan      html  css  js  c++  java
  • vuex 跟 vue属性

    import Vue from 'vue'

    import Vuex,{store} from 'vuex'

    Vue.use(Vuex)

    const store = new store({

    state:{}

    getters:{}过滤改变state

    mutations:{ 改变state,处理同步请求

    changName(state,actions){

      state.name = actions.name 

    }

    }

    <-- 在组件里面 this.$store.commit('changName',{name:"张三'})-->

    actions:{  改变mutations 处理异步请求

      getlist(context){

      context.commit('initlist',{list:res.data})

      <-- 在组件生命周期或事件中

      this.$store.dispatch('getlist')  去触发这个方法

      -->

    }

    }

    })

    --------------------------

    computed:{ 计算属性

      getlist(){

    return Math.floor(Math.random()*this.username)

    }

    } 仅仅在内部依赖的data中数据发生变化时才执行

    watch:{监听属性

    getlist(newval,oldval){}

    基于计算属性来监听新的值跟旧的值

    }

  • 相关阅读:
    MVC架构引入smarty视图引擎
    视图引擎smarty之插件
    视图引擎smarty 三
    视图引擎smarty 二
    视图引擎smarty 一
    .Net 框架
    onkeyup="this.value=this.value.replace(/D/g,'')
    cookie
    click
    html页面内容替换
  • 原文地址:https://www.cnblogs.com/yzy521/p/14155790.html
Copyright © 2011-2022 走看看