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

leaflet
@nuxtjs/leaflet

Leaflet 與 Nuxt 的整合

@nuxtjs/leaflet

Nuxt Leaflet

npm versionnpm downloadsLicenseNuxt

一個使用 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="&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