Emberjs中的本机数组不支持深层复制吗? [英] Native Array in Emberjs does not support deep copy?
本文介绍了Emberjs中的本机数组不支持深层复制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Emberjs中的本机数组不支持深层复制吗?我看到它只是在copy方法中返回切片的数组.是虫子吗?
Native Array in Emberjs does not support deep copy? I saw it just returning sliced array in the copy method. Is it a bug?
推荐答案
当前,这是对Ember的改进,由@adamjmurray报道:
Currently, that's an improvement going on Ember, reported by @adamjmurray: https://github.com/emberjs/ember.js/issues/588
还有一个实现它的命题.您可以像这样使用它:
There's also a proposition to implement it. You can use it like this:
var NativeArray = Ember.Mixin.create(Ember.NativeArray, {
copy: function(deep) {
if (deep) {
return this.map(function(item){ return Ember.copy(item, true) });
} else {
return this.slice();
}
}
});
NativeArray.apply(Array.prototype);
这篇关于Emberjs中的本机数组不支持深层复制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文