123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import Vue from "vue";
- import {
- mapState,
- mapGetters,
- mapActions,
- mapMutations,
- createNamespacedHelpers
- } from "../index";
- const helpers = createNamespacedHelpers('foo');
- new Vue({
- computed: Object.assign({},
- mapState(["a"]),
- mapState('foo', ["a"]),
- mapState({
- b: "b"
- }),
- mapState('foo', {
- b: "b"
- }),
- mapState({
- c: (state: any, getters: any) => state.c + getters.c
- }),
- mapState('foo', {
- c: (state: any, getters: any) => state.c + getters.c
- }),
- mapGetters(["d"]),
- mapGetters('foo', ["d"]),
- mapGetters({
- e: "e"
- }),
- mapGetters('foo', {
- e: "e"
- }),
- helpers.mapState(["k"]),
- helpers.mapState({
- k: "k"
- }),
- helpers.mapState({
- k: (state: any, getters: any) => state.k + getters.k
- }),
- helpers.mapGetters(["l"]),
- helpers.mapGetters({
- l: "l"
- }),
- {
- otherComputed () {
- return "f";
- }
- }
- ),
- methods: Object.assign({},
- mapActions(["g"]),
- mapActions({
- h: "h"
- }),
- mapActions({
- g (dispatch, a: string, b: number, c: boolean): void {
- dispatch('g', { a, b, c })
- dispatch({
- type: 'g',
- a,
- b,
- c
- })
- }
- }),
- mapActions('foo', ["g"]),
- mapActions('foo', {
- h: "h"
- }),
- mapActions('foo', {
- g (dispatch, a: string, b: number, c: boolean): void {
- dispatch('g', { a, b, c })
- dispatch({
- type: 'g',
- a,
- b,
- c
- })
- }
- }),
- mapMutations(["i"]),
- mapMutations({
- j: "j"
- }),
- mapMutations({
- i (commit, a: string, b: number, c: boolean): void {
- commit('i', { a, b, c })
- commit({
- type: 'i',
- a,
- b,
- c
- })
- }
- }),
- mapMutations('foo', ["i"]),
- mapMutations('foo', {
- j: "j"
- }),
- mapMutations('foo', {
- i (commit, a: string, b: number, c: boolean): void {
- commit('i', { a, b, c })
- commit({
- type: 'i',
- a,
- b,
- c
- })
- }
- }),
- helpers.mapActions(["m"]),
- helpers.mapActions({
- m: "m"
- }),
- helpers.mapActions({
- m (dispatch, value: string) {
- dispatch('m', value)
- }
- }),
- helpers.mapMutations(["n"]),
- helpers.mapMutations({
- n: "n"
- }),
- helpers.mapMutations({
- n (commit, value: string) {
- commit('m', value)
- }
- }),
- {
- otherMethod () {}
- }
- )
- });
|