如题,点击按钮,控制台有输出,但是校验提示不显示
<a-form-item v-bind="tempForm.validateInfos.ct2_value">
<a-input-search v-model:value="modelRef1.ct2_value" placeholder="请输入要添加或查询的内容" style="width: 100%" @search="ct2_handleSearch" allowClear />
</a-form-item>
<a-form-item v-bind="tempForm.validateInfos.ct3_value">
<a-select v-model:value="modelRef1.ct3_value" placeholder="请选择值" :options="ct3_options" @change="ct3_handleChange" allowClear></a-select>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="ct2_add()">添加</a-button>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="ct2_search(proxy)">查询</a-button>
</a-form-item>
export default defineComponent({
name: "",
setup() {
// 获取全局属性
const { proxy } = getCurrentInstance();
const modelRef1 = reactive({
ct2_value: '',
ct3_value: undefined
})
const add_rulesRef1 = reactive({
ct2_value: [
{
required: true,
validator: proxy.$validateRule.validateText,
trigger: "change",
whitespace: true,
}
]
,
ct3_value: [
{
required: true,
message: "请选择要添加或查询的值",
trigger: "change",
// whitespace: true,
}
]
})
const search_rulesRef1 = reactive({
ct2_value: [
{
required: false,
validator: proxy.$validateRule.validateForbiddenInput,
trigger: "change",
whitespace: true,
}
]
,
ct3_value: [
{
required: false,
message: "请选择要添加或查询的值",
trigger: "change",
// whitespace: true,
}
]
})
let tempForm = ref({
validateInfos: '',
});
const ct2_add = () => {
tempForm = proxy.$useForm(modelRef1, add_rulesRef1)
tempForm.validate().then(() => {
// 发起接口请求
})
}
const ct2_search = (proxy) => {
tempForm = proxy.$useForm(modelRef1, search_rulesRef1)
tempForm.validate().then(() => {
// 发起接口请求
console.log('执行了码')
})
}
return{
proxy,
modelRef1,
tempForm,
}
}
});