1 Star 7 Fork 7

时不待我 / uniapp-form-generator-parser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

form-generator的uniapp解析器

用于将form-generator导出的JSON解析成一个表单。

依赖

依赖于uview1.8组件库

安装组件

npm i uniapp-form-generator-parser

或者

yarn add uniapp-form-generator-parser

使用示例

查看在线示例

示例代码:

example/index.vue

注意

因为uview表单验证number类型不通过验证,故修改了uview的一点源码组件(其实就是把组件$emit事件的值转化为String字符串类型)如下:

计数器组件:u-number-box 搜索

原来为:

this.emit('input',Number(value));
value:Number(value)

修改为:

this.emit('input', String(value));
value: String(value)

评分组件:u-rate 搜索

原来为:

this.emit('change',this.activeIndex)
this.emit('change',this.activeIndex)
this.emit('input', this.activeIndex) 

修改为:

this.emit(change,String(this.activeIndex))
this.emit(change,String(this.activeIndex))
this.emit('input', String(this.activeIndex))

上传组件:u-upload 搜索 原来为:

this.showToast('超出允许的文件大小');

修改为: this.showToast(超出允许的文件大小${this.maxSize / 1024 /1024}M);

表单组件:u-form-item搜索validation方法

// 检验之间,先获取需要校验的值
this.fieldValue = this.parent.model[this.prop];

之后加入

if(Array.isArray(this.fieldValue)){//如果是数组,转成字符串型通过验证
	this.fieldValue = this.fieldValue.toString();
}

备注: 如果报错误TypeError: Cannot read property 'model' of undefined 尝试修改组件oFormParser里面setTimeout 延迟时间加长。

附件上传支持

暂时仅支持微信小程序端

在node_modules\uview-ui\components

复制u-upload-enclosure文件夹

列如

image-20211220154852639

鸣谢

源代码作者Mr.Liang

点击地址跳转

MIT License Copyright (c) 2021 时不待我 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

用于将form-generator导出的JSON解析成一个表单。 展开 收起
Vue 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/time-doesnt-wait-for-me/uniapp-form-generator-parser.git
git@gitee.com:time-doesnt-wait-for-me/uniapp-form-generator-parser.git
time-doesnt-wait-for-me
uniapp-form-generator-parser
uniapp-form-generator-parser
master

搜索帮助