简体   繁体   English

.get 不是 function:当我获取 js controller 的输入值时,我遇到了错误

[英].get is not a function: When i am getting the value of the input to js controller i am facing the error

I am using input tag inside the iteration to the table.我在表的迭代中使用输入标签。 component.find and get are not working in js controller. component.find 和 get 在 js controller 中不起作用。 Getting the error: This page has an error.收到错误:此页面有错误。 You might just need to refresh it.您可能只需要刷新它。 Action failed:nPrice.get is not a function] Failing descriptor: {c:SP_TCOSandboxLicense$controller$CalculatePrice}操作失败:nPrice.get 不是函数] 失败描述符:{c:SP_TCOSandboxLicense$controller$CalculatePrice}

Component:零件:

    <aura:attribute name="negotiatePrice" type="Integer" />

    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
      <tbody>
        <aura:iteration items="{!v.userList}" var="con" aura:id="usrLst">
          <tr>
             <th scope="row">
                <div class="slds-truncate" title="{!con.Name}">
                    {!con.Name} 
                </div>
             </th>
             <th scope="row">
               <div aura:id="usrLic" class="slds-truncate" title="{!con.TotalLicenses}">{!con.TotalLicenses}</div>
             </th>
             <th scope="row"> 
                <aura:iteration items="{!v.costList}" var="cst">                                     
                  <aura:if isTrue="{!con.Name == cst.Name}">                                   
                    <div class="slds-truncate" title="{!cst.License_Price_Per_Month__c}">{!cst.License_Price_Per_Month__c}</div>
                  </aura:if>
                </aura:iteration>
             </th>
                                        
             <th scope="row" >
               <div class="slds-truncate">
                  <input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField"  value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" /> 
                                   
               </div>
             </th>
                                       
           </tr>   
         </aura:iteration>
     </tbody>
</table>

Controller: Controller:

    CalculatePrice : function(component, event, helper) {  
            
            alert('Calculate');
            var nPrice = component.find("myAtt");
            var negotiatePrice = nPrice.get("v.value");
            alert('negotiatePrice'+negotiatePrice); 
   }

You can basically use the event directly, it will be more efficient: event.target.value基本上可以直接使用event ,效率会更高: event.target.value

Also if I remember correctly from the time I was writing Aura Component, because you provided value={.v.negotiatePrice} you can do component.get('v.negotiatePrice') in your controller to get the value.另外,如果我在编写 Aura 组件时没记错的话,因为您提供了value={.v.negotiatePrice} ,您可以在 controller 中执行component.get('v.negotiatePrice')来获取值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在angularjs中变得未定义时,如何将数组值输入控制器 - how to get an array value into controller as i am getting undefined in angularjs 我得到一个&#39;这不是函数&#39;错误 - I am getting a 'this is not a function' error 为什么我从输入值中得到未定义的错误? - why am i getting undefined error from input value? 当我拥有键和值时,为什么会出现错误? - Why am I getting the error when I have the key and value? 为什么我在这个JS类中得到&#39;不是函数&#39;错误? - Why am I getting an 'is not a function' error in this JS class? 我正在尝试获取类型为checbox的输入的Attribute,但它不断出现此错误:Uncaught TypeError:a.getAttribute不是一个函数 - I am trying to get Attribute of input of type checbox but it keeps getting this error: Uncaught TypeError: a.getAttribute is not a function 我无法正确地将用户输入添加到 state,导致 map 不是 function 错误 - I am not able to add user input to state properly, getting map not a function error when it is 我没有得到过帐的输入值 - I am not getting the posted input value 在控制台中,当我单击带有空白字段的输入按钮时,我在javascript中收到错误 - In Console when I am click the input button with blank field I am getting an error in javascript 为什么我收到错误 app.get is not a function in express.js - Why am i getting an error app.get is not a function in express.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM