javascript - 页面created的时候触发action进行请求,发现vuex state中的状态确实发生了变化,但是页面需要刷新才能渲染列表?
ringa_lee
ringa_lee 2017-04-11 11:47:02
[JavaScript讨论组]
  1. 为什么我的页面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 中对应状态发生了变化,但是需要刷新后,页面中的列表才能渲染成功?

ringa_lee
ringa_lee

ringa_lee

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号