In this exercise, you will learn how to:
In the Developer Console, create a new Lightning Application named PictureGalleryApp.
Implement the app as follows:
<aura:application access="GLOBAL" extends="ltng:outApp">
<aura:dependency resource="c:HelloWorld" />
<aura:dependency resource="c:PictureCarousel" />
</aura:application>
Save the file.
Implement the page as follows:
<apex:page standardStylesheets="false" applyBodyTag="false">
<apex:slds />
<style>
#content {display:flex}
#carousel {height:400px;width:600px;padding-left:12px}
</style>
<div class="slds-scope">
<p>My awesome Lightning Components running in Visualforce...</p>
<div id="content">
<div id="greeting" />
<div id="carousel" />
</div>
</div>
</apex:page>
In Setup, create a tab called PictureGallery for the PictureGallery Visualforce page.
Add the tab to the Dreamhouse Classic app.
Go back to the PictureGallery Visualforce page in the Developer console.
Add the <apex:includeLightning />
tag immediately after the opening <apex:page>
tag.
Add a <script> ... </script>
tag immediately before the closing </apex:page>
tag with the following script to instantiate the HelloWorld component.
<script>
$Lightning.use("c:PictureGalleryApp", function() {
$Lightning.createComponent("c:HelloWorld",
{},
"greeting",
function(cmp) {
console.log("HelloWorld component loaded");
}
);
});
</script>
Save the file.
Go back to the PictureGallery tab and reload the page.
Go back to the PictureGallery Visualforce page in the Developer console.
Add the following code immediately after the existing $Lightning.createComponent
block (within the $Lightning.use("c:PictureGalleryApp"
callback function) to instantiate the PictureCarousel component.
$Lightning.createComponent("c:PictureCarousel",
{slides: [
'https://s3-us-west-1.amazonaws.com/sfdc-demo/houses/living_room.jpg',
'https://s3-us-west-1.amazonaws.com/sfdc-demo/houses/eatinkitchen.jpg',
'https://s3-us-west-1.amazonaws.com/sfdc-demo/houses/kitchen.jpg'
]},
"carousel",
function(cmp) {
console.log("Carousel component loaded");
}
);
Save the file.
Go back to the PictureGallery tab and reload the page.
Switch to Salesforce Classic, click the Picture Gallery tab. The Lightning Components are running in a Visualforce page inside Salesforce Classic.