梦回苍石居  |
Cangshi Live

Lightning Component 问题汇总 - 07.11

LIGHTNING COMPONENTLIGHTNING问题汇总
苍石 发表于:2018-07-12 22:15:57  最后编辑于:1 年前 10 Views

1.向后台传数据时,当server-side-controller方法中接收的参数为sobject的列表时,在需要在前台上传列表的每个对象中设置:

object['sobjectType'] = '指定的sobjet对象类型如:Project__c';


2.在需要触发event的时候,每次使用component.getEvent('Event Name')获取的event只能被触发一次,否则会报错:event has been fired. 

// wrong example
({
    init: function (cmp, event, helper) {
        var event = cmp.getEvent('{event name}');
        cmp.addEventHandler('{event name}', function (e) {
            event.fire(); // the first time can fire the event, but the second time can't
        })
    }
})
// right example
({
    init: function (cmp, event, helper) {
        cmp.addEventHandler('{event name}', function (e) {
            // every time when need to fire a event, first to get it.
            var event = cmp.getEvent('{event name}');
            event.fire();
        })
    }
})

3.当客户端controller获取以自定义的Apex Class返回的结果时,必须使用@AuraEnable 标注Class的每个需要被获取的成员属性。否则在前台获取的每个对象都是空对象。

文章评论 ( 0 )

Person name
未登录用户可以发表匿名评论