分类

链接

2018 年 3 月
 1234
567891011
12131415161718
19202122232425
262728293031  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > Salesforce > 正文
共享办公室出租
Lightning Components Demo
Salesforce 暂无评论 阅读(531)
A component that provides a concrete type-specific input component implementation based on the data to which it is bound.

Represents an input field that corresponds to a field on a Salesforce object. This component respects the attributes of the associated field. For example, if the component is a number field with 2 decimal places, then the default input value contains the same number of decimal places. It loads the input field according to the field type. If the component corresponds to a date field, a date picker is displayed in the field. Dependent picklists and rich text fields are not supported. Required fields are not enforced client-side.

This example creates an input field that displays data for a contact name. Bind the field using the value attribute and provide a default value to initialize the object.

  1. <aura:component controller="ContactController">
  2.     <aura:attribute name="contact" type="Contact" 
  3.                default="{ 'sobjectType': 'Contact' }"/>
  4.     <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  5.     <force:inputField value="{!v.contact.Name}"/>
  6. </aura:component>

In this example, the v.contact.Name expression bounds the value to the Name field on the contact. To load record data, wire up the container component to an Apex controller that returns the contact.

  1. public with sharing class ContactController {
  2.     @AuraEnabled
  3.     public static Contact getContact() {
  4.         return [select Id, Name from Contact Limit 1];
  5.     }
  6. }

Pass the contact data to the component via a client-side controller.

  1. ({
  2.      doInit : function(component, event, helper) {
  3.         var action = component.get("c.getContact");
  4.         action.setCallback(this, function(response) {
  5.             var state = response.getState();
  6.             if (state === "SUCCESS") {
  7.                 component.set("v.contact", response.getReturnValue());
  8.                 console.log(response.getReturnValue());
  9.             }
  10.          });
  11.          $A.enqueueAction(action); 
  12.     }     
  13. })

This component doesn't use the Lightning Design System styling. Use lightning:input if you want an input field that inherits the Lightning Design System styling.

Attributes

Attribute Name Attribute Type Description Required?
body Component[] The body of the component. In markup, this is everything in the body of the tag.
class String The CSS style used to display the field.
errorComponent Component[] For internal use only. Displays error messages for the field.
required Boolean Specifies whether this field is required or not.
value Object Data value of Salesforce field to which to bind.

Events

Event Name Event Type Description
change COMPONENT The event fired when the user changes the content of the input.

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:Lightning Components Demo | Bruce's Blog

发表评论

留言无头像?