luwanquan/babel-preset-vca-jsx

support native events

mesqueeb opened this issue ยท 7 comments

Any plans to support native vue events in the future? :D

Forgive me for not understanding, can you give an example?

I would love to be able to write @click or onClick with the regular event logic, instead of forcing to use props and pass functions to be executed. ๐Ÿ˜„

Currently, the project generated by vue-cli supports onClick by default.

e.g.

const App = createComponent({
  setup() {
    const onClick = () => {
      // do something
    };
    return () => <button onClick={onClick}>test</button>
  }
});

see Example

@luwanquan It's very weird. Because the reason I'm using this package is to use TSX + composition-api.

And the official composition-api docs point to this package: liximomo/vue-composition-api-tsx-example

Which uses your package as only compiler.
And that example project says this:

// Note that this prop must not start with on, otherwise Babel plugin will catch it and process
// it as an event listener and store it to setupContext.listeners.
// For type-safety, we should use function props instead of vue listeners. The prefix "event" is
// for consistence.

 eventClick: {
   type: (null as unknown) as PropType<(event: MouseEvent) => void>,
 }

Are you saying that onEventName but it will never have type safety, so in the case of using this with TSX instead of JSX you need to use eventEventName instead?

Yep. This project does not support security type.

The current project is designed to try some simplified writing, such as setup functional component

Thanks for the info !!! ๐Ÿ˜Š๐Ÿ™