Vue 3 composition api - computed property returns undefined
P粉662089521
P粉662089521 2023-10-31 19:00:10
0
2
493

Using the Vue 3 composition API, how to return the calculated value of the propertyfirstDigit? The keywordthisin the computed property isundefinedbut when I excludethisI get the errorfourDigits is not Defined.

 


P粉662089521
P粉662089521

reply all (2)
P粉557957970

If I need to use a state property to assign a value to another state property, I can do this in the onMounted() hook. like this:

 

Check if it works for you. wish all the best!

    P粉611456309

    thisis something else in the composition API, try using:

    firstDigit: computed(() => { return input.fourDigits[0] })
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!