Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

一个面向业务的 JavaScript/TypeScript 实用程序库。支持在浏览器、Node.js、小程序、Taro、Deno 下使用。

License

NotificationsYou must be signed in to change notification settings

fjc0k/vtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

一个面向业务的 JavaScript/TypeScript 实用程序库。

文档:https://fjc0k.github.io/vtils/v4/

测试报告:https://fjc0k.github.io/vtils/v4-coverage/

import{md5}from'vtils'console.log(md5('龙'))// => 682570a229cbd3d67e76ad99b3152060

特性

安装

# npmnpm i vtils# yarnyarn add vtils# pnpmpnpm add vtils

若在国内,推荐安装tbify 使用淘宝镜像加速:

# npmtnpm i vtils# yarntyn add vtils# pnpmtpm add vtils

使用

在 NodeJS 中使用

// 基础工具库import{wait,isNumber,EventBus,base64Encode}from'vtils'// 日期时间工具库import{formatRelative,subDays,zhCN}from'vtils/date'// React 工具库import{useClassName,useToggle,useScrollLoadMore}from'vtils/react'// 验证工具库import{yup}from'vtils/validator'// 类型工具库import{OmitStrict,LiteralUnion,PartialDeep}from'vtils/types'// 小程序工具库import{getTopBarInfo,navigatePageTo,redirectPageTo}from'vtils/mp'

详细用法见文档:https://fjc0k.github.io/vtils/v4/

在 Taro 3 中使用

Taro 3 中使用前需要修改 Webpack 配置,在config/index.js 中的mini 字段下设置:

mini:{webpackChain(config){// 该插件会影响 resolve.extensions 的表现,删去config.resolve.plugins.delete('MultiPlatformPlugin')// 支持 .taro.js 后缀config.resolve.extensions.prepend('.taro.js')},}

然后,就可以愉快地使用了:

// React 工具库import{useSearchParam}from'vtils/react'// 小程序工具库import{useTopBarInfo}from'vtils/mp'exportdefaultfunction(){constid=+useSearchParam('id')!consttopBarInfo=useTopBarInfo()// ...}

在 Deno 中使用

Deno 下暂只支持基础工具库。

// 基础工具库import{wait,isNumber,EventBus,base64Encode,}from'https://cdn.skypack.dev/vtils@4.129.1'

自定义打包

你可在本地或https://labs.play-with-docker.com/ 上运行下面的命令,然后打开http://localhost:9099,接着选择你需要的工具,最后点击开始打包,等待请求执行完成后即可获取仅包含选中工具的 js 代码以及对应的类型定义。

docker run --rm -p 9099:9099 jayfong/vtils

许可

Jay Fong (c) MIT

About

一个面向业务的 JavaScript/TypeScript 实用程序库。支持在浏览器、Node.js、小程序、Taro、Deno 下使用。

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp