docs: modern js usage example

This commit is contained in:
redhoodsu
2024-07-11 19:47:54 +08:00
parent 0ea3a8bf74
commit 649bbb44ef

View File

@@ -58,7 +58,7 @@ javascript:(function () { var script = document.createElement('script'); script.
You can get it on npm.
```bash
npm install eruda --save
npm install eruda --save-dev
```
Add this script to your page.
@@ -86,6 +86,14 @@ The JavaScript file size is quite huge(about 100kb gzipped) and therefore not su
})();
```
If you are using modern JavaScript tooling, you can dynamically import it.
```javascript
if (import.meta.env.MODE === 'development') {
import('eruda').then(eruda => eruda.default.init());
}
```
## Configuration
When initialization, a configuration object can be passed in.