当前位置:网站首页>URL.createObjectURL、URL.revokeObjectURL、Uint8Array、Blob使用详解
URL.createObjectURL、URL.revokeObjectURL、Uint8Array、Blob使用详解
2022-08-01 09:39:00 【YF-SOD】
目录
URL.createObjectURL(obj)
返回一个URL 对象表示指定的 File 对象(生成blob:http://www.xxxx.com/xx的链接,可以直接在网页上打开File内容)或 Blob 对象(用于下载)。
obj为 File 对象、Blob 对象或者 MediaSource 对象。
URL.revokeObjectURL(objURL)
在每次调用 createObjectURL() 方法时,都会创建一个新的 URL 对象,即使你已经用相同的对象作为参数创建过。当不再需要这些 URL 对象时,每个对象必须通过调用 URL.revokeObjectURL() 方法来释放。
objURL为URL.createObjectURL(obj) 返回的对象。
create|revokeObjectURL使用示例详解
URL.createObjectURL讲解_定栓的博客-CSDN博客_createobjecturl 文件名
arr=new Uint8Array(length)
返回一个长度为length的8位无符号整型数组(存储大小为0~256,负数会自动加256转为整数,超出-256),创建时内容被初始化为0。
还可以接受参数为数组。
arr.BYTES_PER_ELEMENT
数组中每个元素所占用的字节数,返回为1(Uint16Array时返回为2)。
Uint8Array.subarray
和slice方法相似,区别在于subarray返回的数组中的每一位和原数组的每一位共用一个地址(修改返回数组的内容,原数组内容也会对应修改)
示例
相关方法等详解
new Blob(arr,options)
返回一个blob对象(可理解为二进制的数据对象),常用用于文件下载。
arr为存储的数据;option是可选参数,为一个对象,type属性指定数据的类型,可以为text/html、image/png等;endings属性指定包含行结束符\n的字符串如何被写入,native代表行结束符会被更改为适合宿主操作系统文件系统的换行符,transparent代表会保持 blob 中保存的结束符不变(默认值)。
相关方法等详解
边栏推荐
- CTO强烈禁止使用Calendar,那用啥?
- C语言程序设计50例(三)(经典收藏)
- How does UXDB return the number of records for all tables in the current database?
- 改版去不图床 Token 的获取
- SQL Server database schema and objects related knowledge notes
- leetcode-6134: Find the closest node to the given two nodes
- Enterprise WeChat group: robot timing reminder function database configuration
- 杰理AD14N/AD15N---串口中断问题
- 【数据集】各类绝缘子、鸟巢及防震锤数据集汇总
- HoloView -- Tabular Datasets
猜你喜欢
随机推荐
Message queue interview latest finishing (2022)
Introduction and application of heap memory (including examples)
Custom IP used in PCIE
WLAN networking experiment of AC and thin AP
net stop/start mysql80 拒绝访问
MySQL query advanced - from the use of functions to table joins, do you remember?
JVM 运行时数据区与JMM 内存模型详解
MySQL 必现之死锁
SQL Server database schema and objects related knowledge notes
Enterprise WeChat group: robot timing reminder function database configuration
三子棋(C语言实现)
scrapy爬虫框架的使用
程序员如何学习开源项目,这篇文章告诉你
C language game - minesweeper
可视化——Superset安装与部署
HoloView -- Tabular Datasets
STM32个人笔记-程序跑飞
Opencv creates a window - cv.namedWindow()
How programmers learn open source projects, this article tells you
Redis learning









