Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
change computed based on another computed in vue 3

I have this in vue 3. I need to change the title using the prop id if is 0 should be 'New' else 'Details' based on another computed property that I have editMode

setup(props) {
  const {id} = toRefs(props)
  const editMode = computed(() => {
    return id.value !== 0
  })
  const title = computed(() => {
    return editMode ? 'Details' : 'New'
  })
}

the problem is when editMode is false the title is not changing ..... remains 'Details' all the time.

Any idea ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you need to alter editMode to editMode.value inside title compute, given editMode also belongs to Ref type.

const title = computed(() => {
  return editMode.value ? 'Details' : 'New'
})

This should simply solve your problem.

Also try console.log(typeof id.value) to ensure String '0' and Number 0 are not mixed up.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!