OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Can I use ".value" property of a ref() in the <template> section if I want to?

  • Thread starter Thread starter TRDBEI
  • Start date Start date
T

TRDBEI

Guest
TL;DR: I expect .value to work in the template section but it doesn't.

Everywhere I look, even in the official Vue 3 docs, I am told that (paraphrasing) "I don't have to use '.value'" when using refs in the template section because, I quote, "For convenience, refs are automatically unwrapped when used inside templates (with a few caveats).".

Nowhere did I find that I am explicitly required not to use the ".value" property when in the template section. However when I try to use {{ myConstant.value }} in the template section it doesn't work and I get errors.

So is there a way how to use ".value" in the template section when using ref() or is the documentation's (and other unofficial tutorials') wording simply misleading? Perhaps a config in Vue somewhere that I can alter or an alternative non-mustache syntax or something?

The reason I ask is that I actually want to use ".value" in the template section. Why? Because of consistency. I want to see the same consistent syntax everywhere, wherever possible. The less syntax exceptions the better in my book. I don't consider the automatic unwrapping to be a convenience feature - I consider it to be the opposite.
Continue reading...
 
Top