arraybuffer.md 3.4 KB
Newer Older
1 2
# ArrayBuffer

WOSHIMAHAIFENG's avatar
WOSHIMAHAIFENG 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
ArrayBuffer 对象用来表示通用的原始二进制数据缓冲区。

它是一个字节数组,通常在其他语言中称为“byte array”。你不能直接操作 ArrayBuffer 中的内容;而是要通过类型化数组对象

[Float32Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/float32array.html)

[Float64Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/float64array.html)

[Int8Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/int8array.html)

[Int16Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/int16array.html)

[Int32Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/int32array.html)

[Uint8Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/uint8array.html)

[Uint8ClampedArray](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/uint8clampedarray.html)

[Uint16Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/uint16array.html)

[Uint32Array](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/uint32array.html)

[DataView](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/dataview.html) 对象来操作,它们会将缓冲区中的数据表示为特定的格式,并通过这些格式来读写缓冲区的内容。
26 27 28 29 30


## 构造函数


D
DCloud_LXH 已提交
31
### new(byteLength : number) : ArrayBuffer;@Constructor(byteLength)
32 33 34 35 36 37 38

<!-- UTSJSON.ArrayBuffer.Constructor.description -->

<!-- UTSJSON.ArrayBuffer.Constructor.param -->

<!-- UTSJSON.ArrayBuffer.Constructor.returnValue -->

D
DCloud_LXH 已提交
39 40
<!-- UTSJSON.ArrayBuffer.Constructor.test -->

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<!-- UTSJSON.ArrayBuffer.Constructor.compatibility -->

<!-- UTSJSON.ArrayBuffer.Constructor.tutorial -->


## 静态方法


### isView(arg)

<!-- UTSJSON.ArrayBuffer.isView.description -->

<!-- UTSJSON.ArrayBuffer.isView.param -->

<!-- UTSJSON.ArrayBuffer.isView.returnValue -->

57 58
<!-- UTSJSON.ArrayBuffer.isView.test -->

59 60 61 62
<!-- UTSJSON.ArrayBuffer.isView.compatibility -->

<!-- UTSJSON.ArrayBuffer.isView.tutorial -->

63 64 65 66 67 68 69 70 71 72 73 74 75 76
### fromByteBuffer(byteBuffer: ByteBuffer)

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.description -->

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.param -->

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.returnValue -->

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.test -->

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.compatibility -->

<!-- UTSJSON.ArrayBuffer.fromByteBuffer.tutorial -->

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

## 实例属性


### byteLength

<!-- UTSJSON.ArrayBuffer.byteLength.description -->

<!-- UTSJSON.ArrayBuffer.byteLength.param -->

<!-- UTSJSON.ArrayBuffer.byteLength.returnValue -->

<!-- UTSJSON.ArrayBuffer.byteLength.compatibility -->

<!-- UTSJSON.ArrayBuffer.byteLength.tutorial -->


## 实例方法


WOSHIMAHAIFENG's avatar
WOSHIMAHAIFENG 已提交
97
### slice(begin?, end?)
98 99 100 101 102 103 104 105 106 107 108 109 110

<!-- UTSJSON.ArrayBuffer.slice.description -->

<!-- UTSJSON.ArrayBuffer.slice.param -->

<!-- UTSJSON.ArrayBuffer.slice.returnValue -->

<!-- UTSJSON.ArrayBuffer.slice.test -->

<!-- UTSJSON.ArrayBuffer.slice.compatibility -->

<!-- UTSJSON.ArrayBuffer.slice.tutorial -->

111 112 113 114 115 116 117 118 119 120 121 122 123
### toByteBuffer()

<!-- UTSJSON.ArrayBuffer.toByteBuffer.description -->

<!-- UTSJSON.ArrayBuffer.toByteBuffer.param -->

<!-- UTSJSON.ArrayBuffer.toByteBuffer.returnValue -->

<!-- UTSJSON.ArrayBuffer.toByteBuffer.test -->

<!-- UTSJSON.ArrayBuffer.toByteBuffer.compatibility -->

<!-- UTSJSON.ArrayBuffer.toByteBuffer.tutorial -->
WOSHIMAHAIFENG's avatar
WOSHIMAHAIFENG 已提交
124 125 126 127 128


## 注意事项

- iOS的uvue页面编译成js时,可以使用ArrayBuffer,但由于iOS的uts插件暂时不支持ArrayBuffer,所以不能和uts插件进行通信