P粉6681137682023-08-29 09:47:17
storeToRefs
Generate ref()代码>
s.
You say this example "comes directly from the pinia documentation", but I doubt you found ref
propagated anywhere in the pinia documentation. If you do this, then this is a bug and should be pointed out to posva by raising an issue on pinia
's repository.
You can watch it directly for reference:
watch( attributes, handler, { deep: true } )
...or you can use an arrow function to view its .value
1:
watch( () => attributes.value, handler, { deep: true } )
Note that the newVal
and oldVal
parameters are Agent 2. To access its target, use toRaw.
1 - It allows for narrower observers, for example:
watch( () => attributes.value[0]?.value), handler )
2 - If you put an object into ref()
" the object is related to reactive( )
" Perform deep reactions (see Details). Also readReactive Proxy vs. Raw Proxy .