Skip to content

When the form form is submitted, only the error is output in the console, the input box is not marked in red, and no verification prompt is displayed. #5335

@RainLucky

Description

@RainLucky
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.0.1

Environment

window、chrome、vue3.0

Reproduction link

https://segmentfault.com/q/1010000041542530

Steps to reproduce

<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(() => {
console.log('执行了吗——add')

})
}


const ct2_search = (proxy) => {
tempForm = proxy.$useForm(modelRef1, search_rulesRef1)

tempForm.validate().then(() => {

console.log('执行了吗——search')
})
}

return{
proxy,
modelRef1,
tempForm,
}

}
});

What is expected?

点击按钮进行校验,不符合校验规则的,标红并出现提示信息

What is actually happening?

没有出现标红及提示信息,但是control里有输出校验提示信息
image
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions