Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

miniprogram-file

zyrong156MIT2.0.0TypeScript support: included

mini program file polyfill

miniprogram, wx, winxin, 支付宝, 微信, 字节, 小程序, file, polyfill

readme

miniprogram-file

小程序的File polyfill。


支持的小程序

  • 微信小程序
  • 支付宝小程序
  • 字节小程序

    其他小程序没有进行测试,可以自行测试


Example

import File from 'miniprogram-file'

// 设置为全局对象
// globalThis.File = File

const file = new File(["foo"], "foo.txt", {
  type: "text/plain",
});

TIP:
支付宝小程序IDE环境下globalThis为undefined,解决方法
字节小程序所有环境的globalThis都为undefined,暂时无法设置全局变量。


API

参考: https://developer.mozilla.org/zh-CN/docs/Web/API/File

changelog

miniprogram-file

2.0.0

Major Changes

    1. 当环境存在对应依赖时,if 跳过 polyfill
    2. 更新声明文件

    break changes

    1. 编译目标更改为 es6,如果需要 es5 请使用 1.x 版本

Patch Changes