Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sangminnn's avatar

Unexpected constant condition no-constant-condition

Hello :) first, I'm korean and i apologize to my bad english skill.

So, i started to study Frontend(HTML, CSS, JS) about 2 months ago. which means how long i study coding (just 2 months).

and now i start to make something pages using Vue and Vuetify

On the way, i had problem

i made event listener in export default { }

my ex ) methods: { alertt: function () { this.$emit('onoff') } }, created () { this.$on('onoff', function () { if ('gender' === '' || 'age' === '' || 'activity' === '' || 'weight' === '') { return 'true' } else { return 'false' } } ) }

And, in this situation, nuxt said Unexpected constant condition no-constant-condition in if

i don't know what happened.. plz somebody help me.

0 likes
1 reply
gustav1105's avatar

Hi,

Just a tip if you want to post code put your code inside ```

so your code will be

methods: {
 alert: function () { this.$emit('onoff') }
 },

 created () {
 this.$on('onoff', function () 
{ if ('gender' === ' ' || 'age' === ' ' || 'activity' === '' || 'weight' === ' ') 
{ return 'true' } else { return 'false' } } ) }

revised

export default {

    data() {

    return {
    gender: ' ',
    age:  ' ',
    activity: ' ',
    weight: ' '
 } 

},

methods: {

    alert() {
    
    this.$emit('onoff')
}
},

created() {

    //WHAT DO YOU WANT TO DO WITH THE CODE?
    

}

}

post your code!

Please or to participate in this conversation.