Vuex中常用知识点(总结)


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

<template>

  <div class="about">

    <h1>count: <span>{{count}}</span></h1>

    <h1>getCount: <span>{{$store.getters.getCount}}</span></h1>

    <h1>sum: <span>{{sum}}</span></h1>

    <h1>getSum: <span>{{$store.getters.getSum}}</span></h1>

    <button @click="clickB">test    </button>

  </div></template><script>import {mapState, mapGetters, mapMutations, mapActions} from 'vuex';

export default {

  name: 'about',

  data () {

    return {

      count: 0,

      sum: 0

    }

  },

  computed: {

    ...mapState({

      count: state => state.count,

      countAlias: 'count',

      countPlusLocalState (state) {

        return state.count + this.localCount;

      }

    }),

    ...mapGetters([

      'getCount', 'getSum'

    ])

  },

  mounted () {

    this.count = this.$store.state.count;

    this.sum = this.$store.state.a.sum;

 

  },

  methods:{

    ...mapMutations(

      'add','addO'

    ),

    ...mapActions([

      'add','addO'

    ]),

    clickB () {

      this.$store.dispatch('add');

      this.$store.dispatch('addO');

    }

  }

}</script>

相关推荐:

2020年前端vue面试题大汇总(附答案)

vue教程推荐:2020最新的5个vue.js视频教程精选

更多编程相关知识,请访问:编程入门!!

以上就是Vuex中常用知识点(总结)的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

如何解决vue文件里使用背景报错问题

vue中computed和method之间有什么不同点

vue脚手架搭建流程

vue 和 react 的优点有哪些

vue如何动态增加css

vue-loader是什么?

vue-router是什么

vue中如何正确强制组件重新渲染?(方法介绍)

vue常见面试题汇总(附答案解析)

vue.use中发生了什么

更多相关阅读请进入《vue》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...