简体   繁体   English

如何使用传单标记作为nuxt-link?

[英]How can I use a leaflet marker as nuxt-link?

I started to use nuxt and vue-leaflet for an interactive map and i am very new to it.我开始使用 nuxt 和 vue-leaflet 制作交互式地图,我对此很陌生。

The Map contains multiple Markers for different Locations.地图包含不同位置的多个标记。 When the user clicks on a marker the respective page should open.当用户点击标记时,相应的页面应该打开。 Currently a popup opens which contains the link.当前会打开一个包含链接的弹出窗口。

      <l-marker
        v-for="(location, index) in allLocations"
        :key="index"
        :lat-lng="location.latlng"
      >
        <l-popup>
          <nuxt-link :to="getLink(location)">{{
            location.characterName
          }}</nuxt-link>
        </l-popup>
      </l-marker>

but i don't want to use a popup and than the link, I want the link to open when the user clicks on the marker.但我不想使用弹出窗口而不是链接,我希望在用户单击标记时打开链接。 Sadly this code doesn't work:可悲的是,此代码不起作用:

      <nuxt-link
        v-for="(location, index) in allLocations"
        :key="index"
        :to="getLink(location)"
        v-slot="{ href, navigate }"
      >
        <l-marker :lat-lng="location.latlng" :href="href" @click="navigate">
        </l-marker>
      </nuxt-link>

Thanks for any helps and have a good day :) Chris感谢您的帮助,祝您有美好的一天:) 克里斯

如果您将 @click 方法直接绑定到您的 l-marker 并从绑定的方法打开链接怎么办?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM