-
Notifications
You must be signed in to change notification settings - Fork 544
Closed
Description
I made something that I think is worth discussing here.
I made this
work with Vue 3.
For some typical components, it leads to very simple code, check this:
const App = defineStatefulComponent({
setup() {
return {
items: ["Hello", "World"],
newItem: "",
add: () => {
this.items.push(this.newItem)
this.newItem = ""
},
remove(item) {
this.items.splice(this.items.indexOf(item), 1)
},
count: computed(() => this.items.length),
}
}
})
Magic?
You can test it and see how the trick is done here:
https://codesandbox.io/s/nice-engelbart-259gq
chriscalo, stefnotch, kytosai, jstiers, jsbroks and 3 moreIgorHalfeld and septatrix
Metadata
Metadata
Assignees
Labels
No labels