如何处理 npm 包依赖的依赖?
dependencies、devDependencies 还是 peerDependencies? dependencies 用户在使用我的包时,会自动安装 b,但是其实不需要安装b。peerDependencies 要求用户的项目中安装了 b , devDependencies 在 npm i 时,不会自动,符合我的期望,但是我发现 npm 上很多开发者没有把依赖安装到 devDependencies,而是 dependencies...
1 回答880 阅读✓ 已解决
原因在于:我使用了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}])