How to use the state object of vuex

不言
Release: 2018-06-29 17:03:09
Original
1318 people have browsed it

This article introduces you to 5 ways to use the state object of vuex, and posts the structure of my vuex to you. Friends who are interested can follow the editor of Script Home to learn together

vuex It is a state management mode specially designed for vue.js, and can also be debugged using devtools.

The following is the structure of my vuex.

The following is the content of state.js and index.js under the store folder

//state.js const state = { headerBgOpacity:0, loginStatus:0, count:66 } export default state //index.js import Vue from 'vue' import Vuex from 'vuex' import state from './state' import actions from './actions' import getters from './getters' import mutations from './mutations' Vue.use(Vuex) export default new Vuex.Store({ state, actions, getters, mutations })
Copy after login

Let’s start using the vuex state object in the test.vue component

Method 1

  
Copy after login

Method Two

  
Copy after login

Method Three

  
Copy after login

Method 4

  
Copy after login

Method five

  
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to the process of reconstructing multi-page scaffolding based on vue cli

About Vue2 Vue-cli Configuration introduction using Typescript

Vue implements the component that returns the top backToTop

The above is the detailed content of How to use the state object of vuex. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!