wonderful-panda / vue-tsx-support

TSX (JSX for TypeScript) support library for Vue
MIT License
578 stars 40 forks source link

Native event listeners #62

Closed Song-Qian closed 4 years ago

Song-Qian commented 4 years ago

Hello, I have a question in using vue-tsx-support. When I write a component, I need to complete an api function in a vue. <input ...$listeners > I was browsing the vue-tsx-support development documentation and found that it can be used <Component {...{ nativeOn: {click: ...}}} /> So I changed the code to <input type='text' value={ me.value} onInput={ (e) => me.$emit('input', e.target.value)} {...{ nativeOn: {...me .$listeners}} }> But webpack has an error. Should I use this syntax, should I still need the relevant dependencies? image

wonderful-panda commented 4 years ago

Some mistakes exist in your code.

  1. input is not a component, so you can't use nativeOn, use on instead.

    <input {...{ on: this.$listener }} />
  2. In JSX, input tag must be closed. https://stackoverflow.com/questions/30852751/expected-corresponding-jsx-closing-tag-for-input-reactjs

But these maybe not the reason of this error. It seems your babel configuration is something wrong.