state use getter setter is fail #1319
Unanswered
yuntian001
asked this question in
Help and Questions
Replies: 1 comment
-
Use a custom ref within the state instead of a getter+setter: state() {
let _key = ''
return {
key: customRef((track, trigger) => {
return {
get() {
track()
return _key
},
set(newKey: string) {
_key = newKey + 'aa'
localStorage.setItem('key', JSON.stringify(key))
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reproduction
state use getter setter is fail
Steps to reproduce the bug
Expected behavior
Actual behavior
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions