PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 21, 2022

[FIXED] How to display specific DOM only in local?

 August 21, 2022     environment-variables, javascript, vue.js, vuejs2     No comments   

Issue

.env

APP_ENV=local


data() {
        return {
            appEnv: process.env.APP_ENV,

only for local set up, I want to display this debugging section.

<v-col v-if="appEnv == 'local'" cols="6" sm="6" md="9">{{ urlGroups }} </v-col>

I see no error on console, but I also see nothing render from {{appEnv}}

What did I miss ?


Solution

Using a condition in DOM is indirect and unreliable way to debug. Instead process.env.APP_ENV needs to be debugged directly, preferably with a breakpoint.

If it's Vue CLI setup that is used to use .env files then the problem is APP_ENV is not available for browser and it could be debugged that it's undefined.

As the documentation states, custom environment variables should have VUE_APP_ prefix in order to be available in browser. It should be:

VUE_APP_ENV=local

and accessed like process.env.APP_ENV in Vue app.



Answered By - Estus Flask
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing