npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lb-ant-form-dialog

v1.1.0

Published

基于 Ant Design Vue 4.0 的表单

Downloads

3

Readme

lb-ant-form-dialog

基于 Ant Design Vue 的表单插件

Live demo

安装

# vue3
npm install lb-ant-form-dialog -S

使用

vue3 使用

main.ts文件中引入并注册

import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css'

import LbAntFormDialog from 'lb-ant-form-dialog'
const app = createApp(App)
app.use(LbAntFormDialog)

app.use(Antd)

components.d.ts文件中引入并注册

declare module 'vue' {
  export interface GlobalComponents {
    LbAntFormDialog: (typeof import('lb-ant-form-dialog/packages/form-dialog/index.vue'))['default']
  }
}

module.d.ts文件中引入并注册

declare module 'lb-ant-form-dialog'

在页面中使用

<template>
  <lb-ant-form-dialog
    title="标题"
    v-model="formData"
    v-model:visible="visible"
    :formGroup="formGroup"
  >
    <template #customSlot> 插槽~ </template>
  </lb-ant-form-dialog>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import type { IFormGroupsItem } from 'lb-ant-form-dialog/packages'

const visible = ref(false)

interface IFormData {
  name: string
  select: string
  date: string
  range: string
  strDate: string
  endDate: string
  radio: string
  checkbox: string[]
}

// 表单数据
const formData = ref<IFormData>({
  name: '张三',
  select: '16',
  date: '',
  range: '',
  strDate: '',
  endDate: '',
  radio: '',
  checkbox: ['1', '2']
})

// 配置
const formGroup: IFormGroupsItem[] = [
  {
    label: '姓名:',
    // 必填
    required: true,
    targetElement: 'a-input',
    // 数据绑定的 key
    value: 'name',
    // 宽度占这行的 份数,默认:24
    col: 24,
    // form 参数
    formProps: {},
    // form 事件
    formEvents: {},
    // 当前 input 事件
    targetEvents: {},
    // 校验 规则
    rules: [
      {
        validator(value, resolve, reject) {
          if (value === '') {
            reject('不能为空')
          }
          resolve(true)
        },
        trigger: 'blur'
      }
    ]
  },
  {
    label: '下拉选择:',
    targetElement: 'a-select',
    value: 'select',
    props: {
      placeholder: '请选择', //提示内容
      disabled: true
    },
    options: [
      {
        label: '单选框1',
        value: '16'
      },
      {
        label: '单选框2',
        value: '12'
      }
    ],
    fieldNames: {
      value: 'value',
      label: 'title'
    }
  },
  {
    label: '日期选择:',
    targetElement: 'a-date-picker',
    value: 'date',
    required: true,
    props: {
      placeholder: '请选择', //提示内容
      valueFormat: 'YYYY-MM-DD',
      style: 'width: 100%'
    }
  },
  {
    label: '日期区间:',
    targetElement: 'a-range-picker',
    value: 'range',
    required: true,
    props: {
      placeholder: ['起租日期', '结束日期'],
      valueFormat: 'YYYY-MM-DD'
    },
    separateQuery: ['strDate', 'endDate']
  },
  {
    targetElement: 'slot',
    slotName: 'customSlot'
  }
]
</script>

特点

  1. 简单易用,减少代码的重复书写,减少加班;
  2. 提供以 npm 的形式安装提供全局组件;