VDone Demo VDone Demo
Home
  • Articles

    • JavaScript
  • Study Notes

    • JavaScript Tutorial
    • Professional JavaScript
    • ES6 Tutorial
    • Vue
    • React
    • TypeScript: Build Axios from Scratch
    • Git
    • TypeScript
    • JS Design Patterns
  • HTML
  • CSS
  • Technical Docs
  • GitHub Tips
  • Node.js
  • Blog Setup
  • Learning
  • Interviews
  • Miscellaneous
  • Practical Tips
  • Friends
About
Bookmarks
  • Categories
  • Tags
  • Archives
GitHub (opens new window)

Nikolay Tuzov

Backend Developer
Home
  • Articles

    • JavaScript
  • Study Notes

    • JavaScript Tutorial
    • Professional JavaScript
    • ES6 Tutorial
    • Vue
    • React
    • TypeScript: Build Axios from Scratch
    • Git
    • TypeScript
    • JS Design Patterns
  • HTML
  • CSS
  • Technical Docs
  • GitHub Tips
  • Node.js
  • Blog Setup
  • Learning
  • Interviews
  • Miscellaneous
  • Practical Tips
  • Friends
About
Bookmarks
  • Categories
  • Tags
  • Archives
GitHub (opens new window)
  • 基础

  • 组件

  • 过渡&动画

  • 可复用性&组合

  • 工具

  • 规模化

    • Vuex Operations
    • Route Lazy Loading
  • Vuex

  • 其他

  • 《Vue》笔记
  • 规模化
xugaoyi
2020-02-04

Vuex Operations

# Vuex Operations

import { mapActions, mapMutations, mapGetters } from 'vuex'

computed: {
    ...mapGetters([ // Get data, parameter is an array
        'searchHistory' // Equivalent to adding searchHistory and its data to data
    ])
},

methods: {
	someMethod(){
	  this.saveSearchHistory(passedValue)
	},
	...mapActions([ // Dispatch actions to modify data, parameter is an array because the actions file has already encapsulated the methods
      'saveSearchHistory' // Equivalent to binding saveSearchHistory as a method
    ]),

	someMethod() {
		this.setFullScreen(passedValue)
	},
	 ...mapMutations({ // Commit mutations, parameter is an object
      setFullScreen: 'SET_FULL_SCREEN' // Equivalent to binding setFullScreen as a method
    })
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Edit (opens new window)
#Vue
Last Updated: 2026/03/21, 12:14:36
Vue CLI v3 Project Creation Guide
Route Lazy Loading

← Vue CLI v3 Project Creation Guide Route Lazy Loading→

Recent Updates
01
How I Discovered Disposable Email — A True Story
06-12
02
Animations in Grid Layout
09-15
03
Renaming a Git Branch
08-11
More Articles >
Theme by VDone | Copyright © 2026-2026 Nikolay Tuzov | MIT License | Telegram
  • Auto
  • Light Mode
  • Dark Mode
  • Reading Mode