wonderful-panda/vue-tsx-support

v-on syntax error, workaround?

dvic opened this issue · 2 comments

dvic commented

I see that @vue/babel-preset-jsx uses v-on:eventName or vOn:eventName (see https://github.com/vuejs/jsx/tree/dev/packages/babel-sugar-v-on). But I guess this syntax is not supported in TSX because of the double column?

I currently use componentFactoryOf with a methodonEventName() and $emit("eventName") and when I listen with onEventName={...}, this works. But I'm trying to understand why. Are all attributes that start with on put in the on node data object?

dvic commented

@wonderful-panda is this the recommended approach or is there a better way?

Sorry for the late response.

is this the recommended approach

Yes. that way is recommended.

babel-preset-jsx will rewrite onXxx={ ... } to {...{ on: { xxx: ... } }}.