【问题标题】:Aura - Salesforce , "v.remainingBalance" returning undefinedAura - Salesforce,\"v.remainingBalance\" 返回未定义
【发布时间】:2022-12-21 08:35:07
【问题描述】:

CMP

<aura:attribute name="remainingBalance" type="Decimal" />

<lightning:tile label="Update Amount ">
     <div class="slds-grid slds-wrap">
     <div class="slds-col slds-size_1-of-3 slds-align-bottom slds-p-around_medium">
            <lightning:input label="Enter New Amount" value="{!v.remainingBalance}" type="Decimal" ></lightning:input>
                        </div>
                        <div class="slds-col slds-size_1-of-3 slds-align-bottom slds-p-around_medium">  
                            <lightning:button variant="neutral"
                                              label="Update Amount"
                                              title="Update Amount"
                                              disabled="{!v.disableButton}"
                                              onclick="{!c.updateRemainingBalance}"/>
                        </div>
       </div>
       </lightning:tile>

控制器

({
    doInit : function(component, event, helper) {
    },
    updateRemainingBalance: function(component, event, helper) {
        console.log("Check1: " + component.get("v.remainingBalance"));
        helper.validateAndUpdateRemainingBalance(component, event);
    }
})

帮手

({
    validateAndUpdateRemainingBalance : function(component, event) {
        console.log("Check2: " + component.get("v.remainingBalance"));
    }
}) 

`

v.remainingBalance 应该返回 null/value 而不是 undefined

【问题讨论】:

    标签: javascript salesforce lwc aura-framework aura.js


    【解决方案1】:

    你的 'value="{!v.remainingBalance' 只适合显示东西。没有神奇的双向绑定来保存更改。你想将 html 输入更改传输到 ja 变量 - 你需要 onchange() 或类似的处理程序函数。

    https://developer.salesforce.com/docs/component-library/bundle/lightning:input/example 文档中搜索“onchange”和“设置和读取选择索引”一章

    网上有很多关于这个的帖子,例如https://salesforce.stackexchange.com/a/309193/799

    【讨论】:

      猜你喜欢
      • 2019-11-17
      • 1970-01-01
      • 1970-01-01
      • 2016-11-18
      • 2019-12-24
      • 2016-05-15
      • 2017-03-11
      • 2019-07-09
      • 2020-10-02
      相关资源
      最近更新 更多