大佬,根据modelValue传到子级,不能选中

大佬,根据modelValue传到子级,不能选中

<cs-select :multiple=“false” :list=“tags” label-key=“label” value-key=“value” placeholder=“请选择出厂编号” title=“选择出厂编号” clearable :showSearch=“true” :modelValue=“modelValue” :disabled=“showReult” v-model=“model” const modelValue = ref([1]) 没办法选中

2 回复

请提供一下完整的测试项目,并且说明hbuilderx的版本和平台


在你的代码中,modelValuev-model 同时使用导致了数据绑定的冲突。v-model 实际上是 :modelValue@update:modelValue 的语法糖,两者同时存在会产生覆盖。

解决方案:

  1. 移除 :modelValue="modelValue",只保留 v-model="model"
  2. 确保子组件正确触发 update:modelValue 事件

修正后的代码:

<cs-select 
  :multiple="false" 
  :list="tags" 
  label-key="label" 
  value-key="value" 
  placeholder="请选择出厂编号"
  title="选择出厂编号" 
  clearable 
  :showSearch="true"
  :disabled="showReult" 
  v-model="model"
/>
回到顶部