'cmp file' <aura:component > <aura:attribute name="aval" type="Integer"/> <aura:attribute name="bval" type="Integer"/> <aura:attribute name="result" type="Integer"/> <lightning:card title="Calculator" iconName ="standard:lead"> <aura:set attribute="actions"> <lightning:buttonGroup> <lightning:button label="Add" onclcik="{!c.Addme}"/> <lightning:button label="Subtract" onclick="{!c.Subme}" /> <lightning:button label="multiply" onclick="{!c.Mulme}" /> </lightning:buttonGroup> </aura:set> <lightning:input label="enter the first NO" value="{!v.aval}"/> <lightning:input label="enter the second NO" value="{!v.bval}"/> <lightning:input label="result" value="{!v.result}"/> </lightning:card> </aura:component> SO basically the above one is my component code 'Controller code :::::' ''' ({ Addme : function(component) { var A=Component.get("v.aval"); var B=Component.get("v.bval"); var C=a+b; console.log(c); Component.set("v.result",C); }, Subme : function(component) { var A=Component.get("v.aval"); var B=Component.get("v.bval"); var C=ab; Component.set("v.result",C); }, Mulme : function(component) { var A=Component.get("v.aval"); var B=Component.get("v.bval"); var C=a*b; Component.set("v.result",c); } }) here the above one is the controller code where i defined the fucntions for add,sub and mul 'application :' <aura:application extends="force:slds" > <c:v5testing/> </aura:application>Aquí, este es el código de mi aplicación, en el que estoy llamando en general, es simple agregar un problema usando atributos y el concepto de entrada en lightning.
Por favor, ayúdenme, recibo un error de esta manera --> Esta página tiene un error. Es posible que solo necesite actualizarlo. Acción fallida: c:v5testing$controller$Addme [El componente no está definido] Descriptor fallido: {c:v5testing$controller$Addme}
Algunas cosas a tener en cuenta en su código que -
la ortografía de onclick es incorrecta, puede corregirla
<relámpago:button label="Agregar" onclcik="{!c.Agregarme}"/>
Componente y componente son diferentes, ya que javascript es un lenguaje que distingue entre mayúsculas y minúsculas, por lo tanto, trata ambas variables de manera diferente, así que asegúrese de que las variables estén en mayúsculas, minúsculas o mayúsculas correctas.
Intente usar el método javascript parseInt() para convertir los valores en números/enteros, para estar más seguro.
A continuación se muestra su código, que trato de hacerlo sin errores.
archivo cmp
<aura:component > <aura:attribute name="aval" type="Integer"/> <aura:attribute name="bval" type="Integer"/> <aura:attribute name="result" type="Integer"/> <lightning:card title="Calculator" iconName ="standard:lead"> <aura:set attribute="actions"> <lightning:buttonGroup> <lightning:button label="Add" onclick="{!c.Addme}"/> <lightning:button label="Subtract" onclick="{!c.Subme}" /> <lightning:button label="multiply" onclick="{!c.Mulme}" /> </lightning:buttonGroup> </aura:set> <lightning:input label="enter the first NO" value="{!v.aval}"/> <lightning:input label="enter the second NO" value="{!v.bval}"/> <lightning:input label="result" value="{!v.result}"/> </lightning:card> </aura:component>Archivo JS
({ Addme : function(component) { var A=component.get("v.aval"); var B=component.get("v.bval"); var C=parseInt(A)+parseInt(B); console.log(C); component.set("v.result",C); }, Subme : function(component) { var A=component.get("v.aval"); var B=component.get("v.bval"); var C=parseInt(A)-parseInt(B); component.set("v.result",C); }, Mulme : function(component) { var A=component.get("v.aval"); var B=component.get("v.bval"); var C=parseInt(A)*parseInt(B); component.set("v.result",C); } })Archivo de la aplicación
<aura:application extends="force:slds" > <c:v5testing/> </aura:application>Por favor, avíseme si le ayudó, también márquelo como resuelto, si le gusta mi respuesta.
Gracias.