tangjiqiang19
tangjiqiang19
  • 发布:2025-07-08 18:36
  • 更新:2025-07-09 16:01
  • 阅读:144

绑定复杂类型报错

分类:uni-app x

error: When custom components use "v-model" to bind complex expressions, you must specify the type using "as"

v-model="tmp.SrcAlex" ,当绑定一个类中的一个属性的时候会报这个错误

2025-07-08 18:36 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

您好,麻烦发个可复现demo

用户2843246

用户2843246 - 2222

uni-app(Vue 3)

<!-- 错误 -->
<CustomComponent v-model="formData.username" />

<!-- 正确 -->
<CustomComponent v-model="computedValue as number" />
<CustomComponent v-model="formData.username as string" />
<CustomComponent v-model="getFormattedValue() as string" />

要回复问题请先登录注册