Activity › Forums › Salesforce® Discussions › How can we use a Lightning Component in a Salesforce Visualforce Page? Explain?
Tagged: Javascript Library, Lightning Component Framework, Lightning ready Visualforce Page, Salesforce Lightning Components, Salesforce Visualforce Page
-
How can we use a Lightning Component in a Salesforce Visualforce Page? Explain?
Posted by PRANAV on May 1, 2018 at 10:47 AMHow can we use a Lightning component in a Salesforce Visualforce Page? Explain?
Aman replied 8 years ago 3 Members · 2 Replies -
2 Replies
-
Hi pranav,
A Lightning component can be embed in any webpage using a very powerful and flexible feature, Lighting out. When used with Visualforce some complexity becomes simpler.
Lightning component can be added to Visualforce page in three steps:1. We have to first Add the Lightning Components for Visualforce JavaScript library to your targetted Visualforce page using the tag.
2. Next we have to create and refer a Lightning app which is used to the component dependencies.
3. Lastly we need to write a JavaScript function which will finally create the the component on the page using $Lightning.createComponent()
Thanks.
- [adinserter block='9']
-
Hi Pranav,
You can use the following script :
<script>
var accountId = “{!$CurrentPage.parameters.id}”;
console.log(‘::::’+accountId);
$Lightning.use(“TRACT_SF:accountDetailApp”, function() {
$Lightning.createComponent(
“TRACT_SF:accountDetail_LT”,
{ “accountId” : accountId },
“vf-app”,
function(cmp) {
$(“#test”).hide()
console.log(“Component created!”);
console.log(cmp);
});
});
</script>Thanks
Log In to reply.