-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using vModel in Composition API component #169
Comments
has same error : vuejs/composition-api#589 |
Same here, cannot make
(BTW Vue 3 works fine)
babel.config.js: module.exports = {
presets: [
[
'@vue/babel-preset-jsx', {
compositionAPI: true
}
],
[
'@babel/preset-env', {
useBuiltIns: 'entry',
modules: 'auto',
loose: false,
corejs: {
version: 3,
proposals: true
}
}
]
]
} Update: I think it's something to do with the This thing just doesn't work: import { defineComponent, ref } from '@vue/composition-api'
const TinyForm = defineComponent({
setup () {
const name = ref<string | null>(null)
const age = ref<number | null>(null)
return () => (
<div>
<div>
<label>
<span>Username:</span>
<input vModel={name.value} placeholder='Your name.' />
</label>
</div>
<div>
<label>
<span>Age:</span>
<input vModel_number={age.value} placeholder='Your age.' type='number' />
</label>
</div>
<div>
<button>Submit</button>
</div>
</div>
)
}
})
export {
TinyForm
} This thing works: import { defineComponent } from '@vue/composition-api'
const TinyForm = defineComponent({
data: () => ({
name: '',
age: 0
}),
render (h) {
return (
<div>
<div>
<label>
<span>Username:</span>
<input vModel={this.name} placeholder='Your name.' />
</label>
</div>
<div>
<label>
<span>Age:</span>
<input vModel_number={this.age} placeholder='Your age.' type='number' />
</label>
</div>
<div>
<button>Submit</button>
</div>
</div>
)
}
}) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
well since the official Vue 2 JSX support seems to be deprecated, I have made a Vue 2 JSX runtime to support Vue 2 JSX, and it works with TSC/SWC directly, no Babel is needed, and using v-model in setup function no longer throws exceptions. https://github.com/LancerComet/vue2-jsx-runtime @galenjiang @hisuwh @leecervan904 give it a shot |
This comment was marked as duplicate.
This comment was marked as duplicate.
In my project, [
'@vue/babel-preset-jsx',
{
vModel: true,
functional: true,
injectH: true,
vOn: true,
compositionAPI: true,
},
],
<GroupRadio v-model={this.currentBookId} />
<el-input type="textarea" vModel={this.inputText} /> |
This exception only appears when returning JSX which contains |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
2 similar comments
any progress? |
any progress? |
vue2 要结束更新了,这个bug能修复一下吗?100%复现的bug... |
肯定不好修,不然早修了,直接用value+onInput |
I'm getting the following error when using vModel in a JSX/TSX file with the latest version:
Packages:
Component (TSX):
Babel config:
The text was updated successfully, but these errors were encountered: