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

vant3-form-viewer

v0.0.1

Published

基于vue3和vant3的表单填写器,配合element-plus-form-designer

Downloads

1

Readme

vant3-form-viewer

基于 vue3 和 vant3 的表单展现器,结合 element-plus-form-designer.

包含两个组件 FormRenderer 和 FormViewer. FormRenderer 组件用于呈现表单组件和获取表单提交数据,FormViewer 组件查看数据。

npm i vant3-form-viewer

FormDesigner 使用

<script setup>

import { reactive, ref } from 'vue';
import {FormRenderer} from 'vant3-form-viewer';

let formData = reactive({
  "controls": [
    {
      "type": "upload",
      "name": "文件上传",
      "key": "B7C0vljoo",
      "id": "upload_B7C0vljoo",
      "lock": false,
      "dataType": "string",
      "props": {
        "width": 12,
        "showLabel": true,
        "labelWidth": null,
        "label": "文件上传",
        "defaultValue": [],
        "buttonText": "点击上传",
        "sizeUnit": "MB",
        "size": 5,
        "required": false,
        "requiredMessage": "必填字段",
        "multiple": false,
        "withCredentials": false,
        "showFileList": true,
        "accept": ".jpeg,.jpg,.png,.json",
        "limit": 2,
        "disabled": false,
        "tip": "请上传文件",
        "customClass": ""
      },
      "rules": [
        {
          "message": "必填字段",
          "required": true
        }
      ]
    },
    {
      "type": "uploadImage",
      "name": "图片上传",
      "key": "d5CodocO2",
      "id": "uploadImage_d5CodocO2",
      "lock": false,
      "dataType": "string",
      "props": {
        "width": 12,
        "showLabel": true,
        "labelWidth": null,
        "label": "图片上传",
        "defaultValue": [],
        "sizeUnit": "MB",
        "size": 5,
        "required": false,
        "requiredMessage": "必填字段",
        "multiple": false,
        "withCredentials": false,
        "showFileList": true,
        "accept": ".jpg,.png",
        "limit": 1,
        "disabled": false,
        "tip": "",
        "customClass": ""
      },
      "rules": [
        {
          "message": "必填字段",
          "required": true
        }
      ]
    },
  ],
  "props": {
    "labelPosition": "right",
    "labelWidth": 100,
    "size": "default",
    "customClass": "",
    "cols": 12
  },
});
let formModel = reactive({
  upload_B7C0vljoo: [],
  uploadImage_d5CodocO2: [],
});

let uploadOptions = {
  action: 'http://localhost:8888//UploadFile',
  getHeaders: function () {
    return { 'token': '123456' };
  },
  getFileHook: function (res) {
    if (res.success) {
      return {
        name: res.result.url.substr(res.result.url.lastIndexOf('/') + 1),
        url: res.result.url
      };
    } else {
      return res.msg;
    }
  }
}
let formRenderer = ref(null);
function onSubmit(values) {
  console.log("values", values);//提交数据
}
</script>

<template>
  <FormRenderer
    ref="formRenderer"
    @submit="onSubmit"
    :uploadOptions="uploadOptions"
    :formData="formData"
    :formModel="formModel"
  />

  <van-button round block type="primary" @click="formRenderer.submit()">提交</van-button>
</template>

uploadOptions说明:

  • action 表单内上传组件的上传地址。
  • getHeaders 一个方法,返回自定义上传头内容。
  • getFileHook 一个方法,自定义从action返回结果中获取文件信息,成功返回 {name:'文件名称',url:'文件地址'},失败返回错误信息字符串。

FormRenderer 公开的 van-form 的几个方法:

  • validate 对整个表单作验证。
  • submit 提交表单
  • scrollToField 滚动到指定表单字段

FormViewer 使用

属性和 FormRenderer 相同。

联系

邮箱:loogn_0707#126.com ,#自行改为@