Nuxt Leaflet
一個用於使用 Leaflet 的 Nuxt 模組。它是使用 Vue Leaflet 構建的,Vue Leaflet 是 Leaflet 的 Vue 3 封裝,它將原始 Leaflet API 作為 Vue 元件公開。
這個模組的真正目的就是讓它在 Nuxt 中無需任何配置即可工作。
功能
- ⚡ 無需配置
- 🦺 TypeScript 支援
- 🚠 自動匯入
快速設定
npx nuxi@latest module add @nuxtjs/leaflet
就是這樣!您現在可以在 Nuxt 應用中使用 Leaflet 了 ✨
使用
有關可用元件的完整列表,請檢視官方文件庫。
基本
<template>
<div style="height:100vh; width:100vw">
<LMap
ref="map"
:zoom="zoom"
:center="[47.21322, -1.559482]"
:use-global-leaflet="false"
>
<LTileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="&copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors"
layer-type="base"
name="OpenStreetMap"
/>
</LMap>
</div>
</template>
<script setup>
import { ref } from 'vue'
const zoom = ref(6)
</script>
開發
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release