**1、注释:**结构中的ref和@input.native很重要
javascript
<el-form-item label="商品类型:" prop="productType">
<el-select
ref="eleSelect" //这里很重要1
v-model.trim="formData.productType"
placeholder="请选择"
filterable
clearable
@input.native="trimSelect" //这里很重要2
>
<el-option
v-for="item in dictList.SPLX"
:key="item.dictId"
:label="item.dictLabel"
:value="item.dictValue"
></el-option>
</el-select>
</el-form-item>
2、js中限制开头为空格时重新赋值为空
javascript
// 开头为空格时重新赋值为空
const eleSelect = ref()
const trimSelect = ()=>{
let regex = /^\s*$/;
if(regex.test(eleSelect.value.selectedLabel)){
eleSelect.value.selectedLabel = ''
}
}