Skip to content

This <3 Vue #168

@jods4

Description

@jods4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions