zoukankan      html  css  js  c++  java
  • ArrayProxy-Emberjs

    ember 2.18版本API翻译之Ember.ArrayProxy

    import ArrayProxy from '@ember/array/proxy';
    
    ArrayProxy(数组代理)包装实现Ember.Array和/或Ember.MutableArray的任何其他对象,转发所有请求。 这对于大量绑定用例或其他能够交换基础数组的情况非常有用非常有用。对于大量的绑定或其他会交换出底层数组的情况非常有用。
    
        let pets = ['dog', 'cat', 'fish'];
        let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) });
    
        ap.get('firstObject');                        // 'dog'
        ap.set('content', ['amoeba', 'paramecium']);
        ap.get('firstObject');                        // 'amoeba'
    

    这个类同样适用于当被访问时,改变数组的内容。可以通过重写objectAtContent来做:

        let pets = ['dog', 'cat', 'fish'];
        let ap = Ember.ArrayProxy.create({
            content: Ember.A(pets),
            objectAtContent: function(idx) {
                return this.get('content').objectAt(idx).toUpperCase();
            }
        });
        ap.get('firstObject'); // . 'DOG'
    

    原文链接

  • 相关阅读:
    21班考试总结
    性别
    2019.08.20上课笔记2
    2019.08.20上课笔记3
    2019.08.20上课笔记1
    单词2
    数据类和运算符
    2019.08.14单词1
    2019.08.14上课笔记1
    request.get... getHeader 能取得的信息 参数
  • 原文地址:https://www.cnblogs.com/AliceX-J/p/8268657.html
Copyright © 2011-2022 走看看