Object.keys(sortOption).map((k) => { if (key !== k) { this.$set(this.sortOption, k,…
- User
Object.keys(sortOption).map((k) => { if (key !== k) { this.set(this.sortOption, k, false) } else { this.set(this.sortOption, k, true) this.isDown = false } })
this.$set переписать на vue 3 composition api
- Assistant
In Vue 3, the Composition API introduces a different way to handle reactivity. Instead of using
this.$setlike in Vue 2, you use areforreactiveto make your data reactive, and you directly modify the reactive state. Here's an example of how you might translate your code into Vue 3 Composition API format:Assume that you have a
sortOptionobject and you want to toggle its keys based on some condition. First, you'd definesortOptionusingreactive(if it's an object with multiple properties that could change) or (if you're dealing with a single value).