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

el-dialog-form

v3.0.0

Published

基于element-ui封装的弹窗式表单组件

Downloads

32

Readme

el-dialog-form

介绍

基于element-ui封装的弹窗式表单组件

使用说明

  1. 插件基于element-ui开发:element-ui文档
  2. 安装前请先确保已经安装element-ui
  3. npm install element-ui --save
  4. 验证器文档地址:https://github.com/yiminghe/async-validator

安装使用

  1. npm install el-dialog-form --save
全局导入

main.js

import Vue from 'vue';
import ElDialogForm from 'el-dialog-form';
Vue.use(ElDialogForm);
页面导入
import ElDialogForm from 'el-dialog-form';
export default {
	components: {
		ElDialogForm
	}
}

参数说明

| 参数名 | 说明 | 类型 | 可选值 | 默认值 | |---------|-------------|---------|------|-------| | visible | 是否显示dialog | Boolean | true | false | | title | 标题 | String | - | - | | width | 表单宽度 | String | - | - | | items | 表单项,详细见下方说明 | Array | - | [] | | form | 初始表单值 | Object | - | {} |

items参数说明

| 参数名 | 说明 | 类型 | 可选值 | 默认值 | |----------|--------------|---------|------|-------| | elName | 表单项的类型,element ui的组件标签或者slot,必填 | String | el-input/el-input-number/el-radio-group/el-checkbox-group/el-select/el-switch/el-time-picker/el-date-picker/slot | - | | span | el-col的span值 | Number | - | 20 | | label | 表单项label | String | - | - | | prop | 表单项key | String | - | - | | tip | 文字提示 | String | - | - | | rules | 表单验证规则,验证器文档地址:https://github.com/yiminghe/async-validator | Array | - | - | | hidden | 隐藏条件函数,返回true/false来控制显示隐藏 | Function | - | - | | disabled | 禁用条件函数,返回true/false来控制禁用启用 | Function | - | - | | options | 选择项数组,仅type等于radio-group/checkbox-group/select生效,详细见下方说明 | Array | - | - | | on | 事件监听,key->value形式,key值同element-ui的Events,value为一个函数,详见element-ui文档 | Object | - | - | | attrs | 属性参数,key->value形式,key值同element-ui的Attributes,详见element-ui文档 | Object | - | - |

options参数说明

| 参数名 | 说明 | 类型 | 可选值 | 默认值 | |-------|----------|--------|-----|-----| | label | 显示的label | String | - | - | | value | 选中的value | Any | - | - |

elName==='slot'

绑定值为:form

示例代码

<template>
	<div class="app-container">
		<el-button @click="dialog = true">打开表单</el-button>
		<!-- 表单 -->
		<el-dialog-form :visible.sync="dialog" title="表单标题" width="500px" :items="items" :form="form"
			@submit="onSubmit">
		</el-dialog-form>
	</div>
</template>

<script>
	import elDialogForm from 'el-dialog-form'
	export default {
		components: {
			elDialogForm
		},
		data() {
			return {
				form: {
					input: '',
					inputNumber:0,
					switch:false,
					timePicker:'',
					datePicker:'',
					radioGroup:1,
					checkboxGroup:[],
					select:[],
					checkbox:true
				},
				dialog: false,
				items: [
					{
						elName: 'el-input',
						label: '普通输入',
						prop: 'input',
						rules: [{
							required: true,
							message: "请输入名称",
							trigger: 'blur'
						}],
						attrs:{
							placeholder:'请输入名称'
						},
						on: {
							blur: (e) => {
								console.log(e);
							}
						},
					},
					{
						elName: 'el-input-number',
						label: '计数器',
						prop: 'inputNumber',
						on: {
							
						}
					},
					{
						elName: 'el-switch',
						label: '开关',
						prop: 'switch',
						on: {
							
						}
					},
					{
						elName: 'el-time-picker',
						label: '时间选择',
						prop: 'timePicker',
						on: {
							
						}
					},
					{
						elName: 'el-date-picker',
						label: '日期选择',
						prop: 'datePicker',
						attrs:{
							
						},
					},
					{
						elName: 'el-radio-group',
						label: '单选框组',
						prop: 'radioGroup',
						tip:'radio-group说明',
						options:[
							{
								label:'苹果',
								value:1
							},
							{
								label:'西瓜',
								value:2
							}
						],
						on:{
							change:(e)=>{
								console.log('-----------');
								console.log(e);
							}
						}
					},
					{
						elName: 'el-checkbox-group',
						label: '多选框组',
						prop: 'checkboxGroup',
						options:[
							{
								label:'金毛',
								value:1
							},
							{
								label:'哈士奇',
								value:2
							}
						],
						on:{
							change:(e)=>{
								console.log('-----------');
								console.log(e);
							}
						}
					},
					{
						elName: 'el-select',
						label: '下拉选择',
						prop: 'select',
						options:[
							{
								label:'鼠标',
								value:1
							},
							{
								label:'键盘',
								value:2
							}
						],
						attrs:{
							placeholder:'请输入名称'
						},
						on:{
							change:(e)=>{
								console.log('-----------');
								console.log(e);
							}
						}
					},
					{
						elName: 'el-checkbox',
						label: '选择',
						prop: 'checkbox',
						attrs:{
							label:"我同意"
						},
						on:{
							change:(e)=>{
								console.log('-----------');
								console.log(e);
							}
						}
					},
				]
			}
		},
		methods: {
			onSubmit(form) {
				console.log(form);
			}
		},
	}
</script>