李by白
李by白
  • 发布:2018-09-04 16:56
  • 更新:2018-09-04 17:04
  • 阅读:975

动态更新数组没有响应到微信AppData

分类:uni-app
<script>  
  export default {  
    data() {  
      return {  
        articlePageNum: 1,  
        articleHasNextPage: true,  
        articleTypes: [],  
      }  
    },  
    onLoad: function() {  
      this.getList()  
    },  
    methods: {  
      handleClickItem: function(key) {  
        this.$set(this.articleTypes, key, {  
          title: this.articleTypes[key].title,  
          current: true  
        })  
        console.log(this.articleTypes)  
        this.articlePageNum = 1  
        this.articleHasNextPage = true  
        this.getList()  
      },  
      getList: function() {  
        let arr = []  
        for (let i = 0; i < 10; i++) {  
          arr.push({  
            title: '' + i,  
            current: false,  
            currentColor: ''  
          })  
        }  
        this.$set(this, 'articleTypes', [...arr])  
      }  
    }  
  }  
</script>  

2018-09-04 16:56 负责人:无 分享
已邀请:
李by白

李by白 (作者)

找到问题了。。。

李by白

李by白 (作者)

handleClickItem: function(key) {  
        this.$set(this.articleTypes, key, {  
          title: this.articleTypes[key].title,  
          current: true  
        })  
        console.log(this.articleTypes)  
        this.articlePageNum = 1  
        this.articleHasNextPage = true  
        this.getList()  
      },

这个方法中调用了this.getList(),覆盖了上面的操作

该问题目前已经被锁定, 无法添加新回复