이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
English (US)의 문서도 읽어보세요.
The import.meta object is a meta-property exposing context-specific meta data to a JavaScript module. It contains information about the module, like the module's URL.
Syntax
import.meta
Description
The import.meta object consists of the keyword import, a dot, and a property name meta. Normally import. serves as the context for a property access, but here import. is not really an object.
The import.meta object is created by the ECMAScript implementation, with a null prototype. The object is extensible, and its properties are writable, configurable, and enumerable.
Examples
Given a module my-module.js
<script type="module" src="my-module.js"></script>
you can access meta information about the module using the import.meta object.
console.log(import.meta); // { url: "file:///home/user/my-module.js" }
It returns an object with a url property indicating the base URL of the module. This will either be the URL from which the script was obtained, for external scripts, or the document base URL of the containing document, for inline scripts.
Specifications
| Specification | Status | Comment |
|---|---|---|
import.meta proposal |
Stage 3 | Initial definition |
| HTML Living Standard The definition of 'import.meta' in that specification. |
Living Standard | Defines import.meta properties in HTML. |
Browser compatibility
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
import.meta | Chrome Full support 64 | Edge ? | Firefox Full support 62 | IE No support No | Opera Full support 51 | Safari Full support 11.1 | WebView Android Full support 64 | Chrome Android Full support 64 | Firefox Android Full support 62 | Opera Android Full support 47 | Safari iOS Full support 12 | Samsung Internet Android No support No | nodejs ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown