- Home.vue
/*
* @Descripttion: 規範自己,寫出優質量程式碼
* @version: 1.0
* @Author: baojino
* @Date: 2021-11-01 15:38:58
* @LastEditors: Aidam_Bo
* @LastEditTime: 2021-11-01 17:46:32
*/
import { createStore } from 'vuex'
export default createStore({
state: {
name: 'dell'
},
mutations: {
changeName(state ,str) {
// this.state.name = 'chensan'
state.name = str
},
getData(state ,str) {
state.name = str
}
},
actions: {
getData() {
setTimeout(() => {
this.commit('getData','liming')
}, 2000)
},
},
modules: {
}
})
``````html
/*
* @Descripttion: 規範自己,寫出優質量程式碼
* @version: 1.0
* @Author: baojino
* @Date: 2021-11-01 15:38:58
* @LastEditors: Aidam_Bo
* @LastEditTime: 2021-11-01 17:46:32
*/
import { createStore } from 'vuex'
export default createStore({
state: {
name: 'dell'
},
mutations: {
changeName(state ,str) {
// this.state.name = 'chensan'
state.name = str
},
getData(state ,str) {
state.name = str
}
},
actions: {
getData() {
setTimeout(() => {
this.commit('getData','liming')
}, 2000)
},
},
modules: {
}
})
``````html
/*
* @Descripttion: 規範自己,寫出優質量程式碼
* @version: 1.0
* @Author: baojino
* @Date: 2021-11-01 15:38:58
* @LastEditors: Aidam_Bo
* @LastEditTime: 2021-11-01 17:46:32
*/
import { createStore } from 'vuex'
export default createStore({
state: {
name: 'dell'
},
mutations: {
changeName(state ,str) {
// this.state.name = 'chensan'
state.name = str
},
getData(state ,str) {
state.name = str
}
},
actions: {
getData() {
setTimeout(() => {
this.commit('getData','liming')
}, 2000)
},
},
modules: {
}
})
我的名字是:{{name}}
改變
```
- store\index.js
/*
* @Descripttion: 規範自己,寫出優質量程式碼
* @version: 1.0
* @Author: baojino
* @Date: 2021-11-01 15:38:58
* @LastEditors: Aidam_Bo
* @LastEditTime: 2021-11-01 17:46:32
*/
import { createStore } from 'vuex'
export default createStore({
state: {
name: 'dell'
},
mutations: {
changeName(state ,str) {
// this.state.name = 'chensan'
state.name = str
},
getData(state ,str) {
state.name = str
}
},
actions: {
getData() {
setTimeout(() => {
this.commit('getData','liming')
}, 2000)
},
},
modules: {
}
})
本作品採用《CC 協議》,轉載必須註明作者和本文連結