tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
16.11k stars 1.67k forks source link

目前upload 组件没有办法自动与 form 配合 做数据动态校验,只能手动触发 #5239

Closed wxwebfeng closed 1 week ago

wxwebfeng commented 1 year ago

This function solves the problem (这个功能解决的问题)

表单中有附件必填,上传了之后 form校验提示还是一直提示,需要开发者去手动触发校验才能清除,或者本有一个附件用户删除了,逻辑上是需要提示用户这是必填,期待后期能与formItem的 handleContentChange 方法触发自动校验

Expected API (期望的 API)

表单中有附件必填,上传了之后 form校验提示还是一直提示,需要开发者去手动触发校验才能清除,或者本有一个附件用户删除了,逻辑上是需要提示用户这是必填,期待后期能与formItem的 handleContentChange 方法触发自动校验

web-wade commented 5 months ago

有合适方案吗

easy868 commented 4 months ago

同样的问题,有合适方案吗

qlj1997 commented 1 week ago

image

借助 vite-plugin-vue-devtools 发现 n-form-item 注入 image

// UploadImage.vue  

import type { FormItemInjection } from 'naive-ui/es/_mixins/use-form-item';  
const formItem = inject<FormItemInjection>('n-form-item');  
...
formItem?.handleContentChange(); // 上传成功后调用

image

jahnli commented 1 week ago

Through custom upload, callback successfully verifies the form