Getting env data inside components is easy task to do, if you want to learn how? follow simple steps below and you'll be able to have your env data inside your components.
Step 1:
Add new value in your env file and mark it with MIX like follow
MIX_APP_NAME=Laravel
//OR
MIX_APP_DOMAIN=example.comStep 2:
Call for env data in component.
data() {
return {
app_name: process.env.MIX_APP_NAME,
site_domain: process.env.MIX_APP_DOMAIN,
}
}, process + env + your variable
Step 3:
Print values in template
${app_name}
// OR
{{ app_name }}
//ALSO
${site_domain}
// OR
{{ site_domain }}
Easy right?
- Last updated 4 years ago
Be the first to leave a comment.
You must login to leave a comment