---
title: "useScriptLeaflet"
description: "当你需要直接访问 Leaflet 命名空间或构建自己的地图组件时，请使用 useScriptLeaflet()。"
canonical_url: "https://nuxt-scripts.zhcndoc.com/scripts/leaflet/api/use-script-leaflet"
last_updated: "2026-09-23T10:33:13.094Z"
---

当你需要直接访问 Leaflet 命名空间或构建自己的地图组件时，请使用 `useScriptLeaflet()`{lang="ts"}。

::script-types{script-key="leaflet" filter="useScriptLeaflet"}
::

```ts
const { onLoaded } = useScriptLeaflet()

onLoaded(({ L }) => {
  const bounds = L.latLngBounds(points)
  // 直接使用 Leaflet API。
})
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
