GithubHelp home page GithubHelp logo

Comments (6)

lzhoucs avatar lzhoucs commented on May 13, 2024 4

This is what I came up with. Not any better looking, but no spread. It would be nice if .sync can be supported natively in jsx.

<VDataTable
  pagination={this.pagination}
  on={
    {
        "update:pagination": newVal ⇒ (this.pagination = newVal)
    }
  }

from jsx-vue2.

6XGate avatar 6XGate commented on May 13, 2024 1

@nickmessing

the onUpdate:myprop or on-update:myprop should work, if you have issues with that open another issue

onUpdate:prop does not work. should a new issue be filed or can this one be reopened?

from jsx-vue2.

DaleMckeown avatar DaleMckeown commented on May 13, 2024

You don't have to use JSX spread to do this.

You can use the syntax below, which calls an anonymous function when the change event is triggered.

<MyComponent myprop={this.myprop} on-change={(val)=> {this.myprop = val; }} />

However, a better way would be to use the v-model directive. Usually, this is attached to the input event, but it has a lazy modifier that binds to the change event instead:

<MyComponent v-model_lazy={this.myprop} />

from jsx-vue2.

Dylan-Chapman avatar Dylan-Chapman commented on May 13, 2024

Sorry, I should clarify that this is in the case where myprop is not the component's model. For example, Vuetify's pagination prop on their data tables.

from jsx-vue2.

DaleMckeown avatar DaleMckeown commented on May 13, 2024

Ah, I see. I don't think .sync is supported directly, but manually listening to the update events should work, assuming it is being emitted in the component.

Have you tried:

<MyComponent myprop={this.myprop} on-update:myprop={(val) => { this.myprop = val; }}

The : character might be a bit tricky, I haven't tried listening to emitted events in this way. I'd also suggest trying on-update_myprop and on-updatemyprop in case these are being handled.

You could also change the emitted event name to remove the colon character.

Other than that, spread may be the only way at the moment.

from jsx-vue2.

nickmessing avatar nickmessing commented on May 13, 2024

the onUpdate:myprop or on-update:myprop should work, if you have issues with that open another issue @Dylan-Chapman

from jsx-vue2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.