Writing in the front

Although this demo has few functions, most of the vuex knowledge points are in it

Application item address portal agent address is here

This is written with VUe2.0 high copy of Vivo store address here

If you feel helpful to you, please point a star. Thank you. Thank you!

Front-end exchange group 740625675 like-minded can be added to learn together!

Code review

Vuex official documentation https://vuex.vuejs.org/ I think the official documentation is very detailed

LocalStorage is used to store data locally

const state={
    home:localStorage["home"]? JSON.parse(localStorage["home"]): [],
    item:localStorage["item"]? JSON.parse(localStorage["item"] : [],}export default state

Copy the code
const mutations={
    
    [types.SET_SHIXIANG](state,data){
        state.home.push(data)
        localStorage.setItem("home",JSON.stringify(state.home));
    },
   
    [types.SET_YES](state,data){
        state.item.push(data)
        localStorage.setItem("item",JSON.stringify(state.item)); }}export default mutations

Copy the code
const actions={
    setOrder ({commit}, data) {
        commit('SET_SHIXIANG', data);
    },
    setYes({commit},data){
        commit('SET_YES',data)
    }
}
export default actions

Copy the code

Project screenshots


Project running

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build
Copy the code

Write in the last

A front-end intern, do not do well, but also hope the big mouth soft spray big guy I want a star