Salesforce Lightning 使用lightning:dualListbox报错“Can not read property 'xxx' of undefined”

https://salesforce.stackexchange.com/questions/210323/lightningduallistbox-error-in-spring-18?noredirect=1#comment317091_210323

原因是lightning:dualListbox控件需要写全”label”, “sourceLabel”, “selectedLabel”, “options”属性。
参考官网写法:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_dualListbox.htm

<aura:component>
    <aura:attribute name="listOptions" type="List" default="[]"/>
    <aura:attribute name="defaultOptions" type="List" default="[]"/>
    <aura:attribute name="requiredOptions" type="List" default="[]"/>
    <aura:handler name="init" value="{! this }" action="{! c.initialize }"/>
    <lightning:dualListbox aura:id="selectOptions" name="Select Options"  label= "Select Options" 
                           sourceLabel="Available Options" 
                           selectedLabel="Selected Options" 
                           options="{! v.listOptions }"
                           value="{! v.defaultOptions }"
                           requiredOptions="{! v.requiredOptions }"
                           onchange="{! c.handleChange }"/>
</aura:component>

猜你喜欢

转载自blog.csdn.net/rosechan/article/details/79452151