tencent cloud

Tencent Cloud Observability Platform

open

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-11 19:41:08
The open built-in function is used to open files.
open(filePath: string, mode?: '' | 'b'): string | ArrayBuffer

Parameters

Parameter
Type
Description
filePath
string
The relative path to the file.
mode?
'' or 'b'.
Open mode (optional). For text files, it is not necessary to specify a mode, and the return value is a string; for binary files, 'b' mode should be passed, and the return value is an ArrayBuffer.

Return

Type
Description
string or ArrayBuffer.
File data.

Samples

Open files:
export default function () {
let data = open('test1.json'); // Open text files by default.
console.log(data); // {"a":"b"}
data = open('test2.bin', 'b'); // Open binary files in 'b' mode.
console.log(data); // [object ArrayBuffer]
};


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백