vue学习记录 coderwhy d11 12

Posted Kooklen_xh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue学习记录 coderwhy d11 12相关的知识,希望对你有一定的参考价值。





new Promise((resolve,reject)=>
    setTimeout(function ()
      resolve('hello_world')
      reject('error data')
    ,520)
  ).then(data=>
    console.log(data);
  ,error=>
    console.log(error)
  )








<template>
  <div id="app">
    <h3>$store.state.counter</h3>
    <button @click="add">+</button>
    <button @click="min">-</button>
    <h1>hello world</h1>
  </div>
</template>

<script>
export default 
  name: 'App',
  methods:
    add()
      this.$store.commit('increment')
    ,
    min()
      this.$store.commit('decrement')

    
  

</script>


import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store(
  state: 
    counter: 520
  ,
  mutations: 
    increment (state) 
      state.counter++
    ,
    decrement(state)
      state.counter--
    
  ,
  actions:,
  getters:,
  modules:
)

export default store



  getters:
    powerc(state)
      return state.counter * state.counter
    ,
    more20stu(state)
      return state.student.filter(s => s.age > 20)
    ,
    more20stulength(state,getters)
      return getters.more20stu.length
    ,
    moreAgestu(state)
      return function(num)
       return state.student.filter(s => s.age > num)

    
  ,```
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210609180714270.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDg1NzY0OA==,size_16,color_FFFFFF,t_70)

```javascript
 addd(num)
    this.$store.commit('addd',num)
  
addd(state,num)
      
        state.counter+=num

      

 mutations: 
    addd(state,payload)
      
        state.counter += payload.num

      
    ,
 addd(num)
    this.$store.commit(type:'addd',num)
,

以上是关于vue学习记录 coderwhy d11 12的主要内容,如果未能解决你的问题,请参考以下文章

vue学习记录 coderwhy d7

vue学习记录 coderwhy d7

vue学习记录 coderwhy d13

vue学习记录 coderwhy d13

vue学习记录 coderwhy d8

vue学习记录 coderwhy d8