为什么我的页面created的时候触发action进行请求数据,
created () {
this.postEvent()
},
methods: {
...mapActions([
'changeatteintionList'
]),
postEvent () {
this.message.bankId = this.collectItems.ologoinMessage.obj_bak2.bankId
this.changeatteintionList(this.message) // 触发action
}
action中的代码:
import {ajaxPost} from '../../commonJS/hashParam.js'
import {roleSearchApi} from '../../api.js'
export default {
changeatteintionList ({commit, state}, data) {
console.log(data)
// commit('changeatteintionList', data)
ajaxPost(roleSearchApi, data, (response) => {
if (response.data.status === 'success') {
console.log(window.JSON.stringify(response.data.obj))
commit('changeatteintionList', response.data.obj)
}
})
}
}
mutations中的代码:
changeatteintionList (state, data) {
sStorage(state, 'oatteintionList', data)
},
但是发现vuex state 中对应状态发生了变化,但是需要刷新后,页面中的列表才能渲染成功?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ringa_lee