Creating Components with Third-Party Libraries
Overview
Prerequisites
Component Lifecycle Hooks
Available Hooks
Hook
When it Fires
Use For
Execution Order
Complete Example: FullCalendar Component
Step 1: Component Structure
Step 2: Load the Library (onBeforeMount)
Step 3: Initialize the Library (onMount)
Step 4: Add Cleanup (onBeforeDestroy)
Step 5: Add Custom Actions (Optional)
Complete Working Component
Using the Component on a Page
Providing Event Data
Adding Navigation Buttons
Common Patterns
Pattern 1: Simple Library (No DOM Access)
Pattern 2: Library Needing DOM Access
Pattern 3: Singleton Initialization
Important: DOM Access in namedActions
β What DOESN'T Work
β
What DOES Work
Best Practice: Use id Attributes
id AttributesAnother Example: Chart.js Component
Finding CDN URLs for Libraries
Option 1: jsDelivr (Recommended)
Option 2: Library's Official Docs
Loading CSS Stylesheets
Troubleshooting
Issue: "Element not found" in onMount
Issue: Library is not defined
Issue: Component works but memory leak
Issue: "this.$refs is not a function"
Issue: "schema is not defined"
Best Practices
β
DO:
β DON'T:
More Examples
Leaflet Maps
CodeMirror Editor
Quick Reference Checklist
See Also
Next Steps
Last updated
Was this helpful?