首页 > 其他分享 >ant-design-vue

ant-design-vue

时间:2022-12-03 17:33:31浏览次数:39  
标签:vue name rules ant design 组件

vue3引入ant-design-vue UI组件

  1. 安装
npm i --save ant-design-vue@next -S
  1. 在main.js全局引入
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

createApp(App).use(Antd).mount('#app');
  1. 使用组件:查看文档,例如:
<a-button type="primary">点击</a-button>

认识表单组件

  1. Form && FormModel 区别:FormModel支持v-model指令,推荐使用FormModel
  2. Form 组件提供了表单验证的功能,通过 rules 属性传入约定的验证规则,并将 FormItem 的 prop 属性设置为需校验的字段名
<a-form-model
    ref="ruleForm"
    :model="form"
    :rules="rules"
    :label-col="labelCol"
    :wrapper-col="wrapperCol"
  >
    <a-form-model-item ref="name" label="Activity name" prop="name">
      <a-input
        v-model="form.name"
        @blur="
          () => {
            $refs.name.onFieldBlur();
          }
        "
      />
    </a-form-model-item>
</a-form-model>

model : 表单数据对象
rules : 定义校验规则

rules: {
    name: [
      { required: true, message: 'Please input Activity name', trigger: 'blur' },
      { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
    ],
};

标签:vue,name,rules,ant,design,组件
From: https://www.cnblogs.com/4shana/p/16948411.html

相关文章

  • vue
    安装安装nodejs环境命令行npminstall-g@vue/cli创建项目vuecreate<project>安装依赖cd<project>npminstall运行项目npmrunserve配置......
  • 从头再学Vue
    第一篇章动态绑定多个值如果有想这样的一个包含多个attribute的JavaScript对象:constobj={id:'container',class:"wrap"}可以通过不带参数的v-bind将这些att......
  • 全局引入element-plus/icons-vue
    安装npminstall@element-plus/icons-vuemain.js...import*asElementPlusIconsVuefrom'@element-plus/icons-vue'for(const[key,component]ofObject.entr......
  • 为什么是Instantiate all remaining (non-lazy-init) singletons,而不是Instantiate al
    阅读spring源码时,注意到一个小细节,在核心方法refresh()中我们都知道,bean的实例化发生在finishBeanFactoryInitialization(beanFactory)方法中入上图,finishBeanFactoryInitia......
  • reentrantlock锁,生产者,消费者
    reentrantlock和synchronized的区别是,可以指定两个或者多个队列,唤醒指定队列的线程      生产者消费者,一个锁对象有两个队列,一个是生产者队列,一个是消费者队......
  • Vue 中的 Ref
    Vue中的Ref1:ref说明<!--##ref属性1.被用来给元素或子组件注册引用信息(id的替代者)2.应用在html标签上获取的是真实DOM元素,应用在组件标签上是组件实......
  • Altium Designer电路设计软件下载
    关注微信公众号【工控羊】或者微信号【gksheep】,微信公众号后台输入数字编号【0010】即可获取下载链接。......
  • vue-router
    1.安装[email protected]要指定版本号否则会报错2.使用2.1在src下创建router目录,在其中新建index.js文件importVueRouterfrom......
  • 使用Kafka Assistant监控Kafka关键指标
    使用KafkaAssistant监控Kafka关键指标使用Kafka时,我们比较关心下面这些常见指标。KafkaAssistant下载地址:​​http://www.redisant.cn/ka​​broker度量指标活跃控制器数......
  • uni 结合vuex 编写动态全局配置变量 this.baseurl
    在日常开发过程,相信大家有遇到过各种需求,而我,在这段事件便遇到了一个,需要通过用户界面配置动态接口,同时,因为是app小程序开发,所以接口中涉及到了http以及websocket两个类型......