Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[新功能需求] form表单自定义error #882

Open
ST-log opened this issue Feb 10, 2025 · 0 comments
Open

[新功能需求] form表单自定义error #882

ST-log opened this issue Feb 10, 2025 · 0 comments
Labels
feature: need confirm 待确认的新特性

Comments

@ST-log
Copy link

ST-log commented Feb 10, 2025

这个功能解决了什么问题?

对于form表单自定义error,抛出一个 自定义错误的slot

你期望的 API 是什么样子的?

// 现在
<wd-form ref="form" :model="model">
  <wd-cell-group border>
    <wd-input
      label="用户名"
      label-width="100px"
      prop="value1"
      clearable
      v-model="model.value1"
      placeholder="请输入用户名"
      :rules="[{ required: true, message: '请填写用户名' }]"
    />
  </wd-cell-group>
  <view class="footer">
    <wd-button type="primary" size="large" @click="handleSubmit" block>提交</wd-button>
  </view>
</wd-form>
// 想要的
<wd-form ref="form" :model="model">
  <wd-cell-group border>
    <wd-input
      label="用户名"
      label-width="100px"
      prop="value1"
      clearable
      v-model="model.value1"
      placeholder="请输入用户名"
      :rules="[{ required: true, message: '请填写用户名' }]"
    >
       <template #error="{ msg }">
           <view>{{ msg }} </view> // rule自定义的msg
      </template>
   </wd-input>
  </wd-cell-group>
  <view class="footer">
    <wd-button type="primary" size="large" @click="handleSubmit" block>提交</wd-button>
  </view>
</wd-form>
@ST-log ST-log added the feature: need confirm 待确认的新特性 label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: need confirm 待确认的新特性
Projects
None yet
Development

No branches or pull requests

1 participant