1 个回答

原因在于:我使用了mobx来作为数据中心的存储
将ObserverArray 转为原生Es6的Array
toJS slice() peek() // 来自mobx官网

注意:
[].push('1') // 得到的不是数组 而是 1
这个时候用concat
// const history = [...this.dataHistory.slice(), ...[{hash: location.hash, data: data}]]
console.log('123', this.dataHistory)
// console.log('456', this.dataHistory.slice())
// console.log('789', this.dataHistory.slice().push({hash: location.hash, data: data})) // !!!得到 1
const history = this.dataHistory.peek().concat([{hash: location.hash, data: data}])

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题