透過超過 100 個技巧的集合來學習 Nuxt!

leaflet
@nuxtjs/leaflet

Leaflet 與 Nuxt 的整合

@nuxtjs/leaflet

Nuxt Leaflet

npm versionnpm downloadsLicenseNuxt

一個用於 Nuxt 的 Leaflet 模組。它使用 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="&amp;copy; <a href=&quot;https://www.openstreetmap.org/&quot;>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 ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release