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

formline-vue3

v0.0.38

Published

简化表单代码; 只写一串<template>, 然后配置数组即可; 可无脑复制粘贴;

Downloads

142

Readme

说明

  • 安装: npm install formline-vue3
  • 推荐环境: Vue3 + ElementPlus
  • 使用场景
    • 使用 "ElementPlus" 制作表单时,一般需要在 "template"部分编写很多 "表单组件"代码,代码量大。且写完一个组件代码后复制粘贴到第二个组件上时,需要检查是否有不必要的代码。如果使用 "formline-vue3",可以真正的 "无脑复制粘贴",且对代码友好。
    • 当表单存在复杂的场景(比如 "根据某个下拉框的值来切换其他表单项的内容)时,常规写法会导致你的 "template"中出现大量的"<if><else>",且需要同步修改较多变量。使用 "formline-vue3",只需要在 "javascript"代码部分操作数组的内容即可。
  • 包内容
    • FlUI:封装 "ElementPlus"的常规表单组件(例如:ElCheckbox、ElColor、ElDate、ElDateRange、ElDateTime、ElDateTimeRange、ElInput、ElMulti、ElNumber、ElRadio、ElSelect、ElSwitch、ElTextarea、ElTime、ElTimeRange)。
    • FlEntity:"FlUI" 的实例对象,以及一些功能函数(就是 "FlUI"内部使用的数据对象,直接传入 "FlUI"的props即可)。
  • 源码使用 "vue3+vite+ts" 实现,不过第三方项目暂时好像没有ts提示支持,后续更新会支持。

简单使用 Demo

<!-- template -->
<template v-for='(item,index) in _formList.list' :key='item.cid'>
  <el-form-item :label='item.getName' :prop='item.ident'>
    <FlUI
      :index='index' :seq='-1' :entity='item'
      @changeValue='(index, seq, event)=> _formList.setValue(event, index)'
    />
  </el-form-item>
</template>
<el-button @click='_bindSubmit'>提交</el-button>

<!-- script -->
import { reactive } 'vue';
import { FlEntity, FlUI } from 'formline-vue3'; // 引入

// 使用 "FlEntity"中的 "ClassList"创建一个数组, 用来装载所有自定义实例对象
const _formList = reactive(new FlEntity.ClassList.builder([
  // 创建一个 "input"组件的 "数据实例"
  // (唯一标识='userName', label='UserName', 输入框占位符='Please Input UserName', 默认值='')
  FlEntity.ClassInput.builder('userName', 'UserName', 'Please Input UserName', ''),

  // 创建一个 "number"组件的 "数据实例"
  // (唯一标识='amount', label='Amount', 输入框占位符='', 默认值=12)
  FlEntity.ClassNumber.builder('amount', 'Amount', '', 12),
]));

function _bindSubmit() {
  // 通过 "FlEntity"中的工具函数, 获取 "表单输入内容"的结果集合
  console.log('result', _formList.calcResult(true));
}

详细文档