【发布时间】:2019-12-14 00:34:41
【问题描述】:
我正在尝试使用 Vue2Leaflet 组件 (https://vuejsexamples.com/vue-2-components-for-leaflet-maps/),但我很难让它工作。我无法使用 html 文件使这个简单的示例工作:
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet/dist/leaflet.css" />
</head>
<body>
<div id="app" style="height: 400px">
<v-map :zoom=13 :center="[47.413220, -1.219482]">
<v-tilelayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"></v-tilelayer>
<v-marker :lat-lng="[47.413220, -1.219482]"></v-marker>
</v-map>
</div>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="https://unpkg.com/vue2-leaflet"></script>
</body>
</html>
还有js文件:
Vue.component('v-map', window.Vue2Leaflet.LMap)
Vue.component('v-tilelayer', window.Vue2Leaflet.TileLayer)
Vue.component('v-marker', window.Vue2Leaflet.Marker)
new Vue({ el: '#app'});
我对这个基本示例做了一个小技巧:http://jsfiddle.net/rvxc2uLk/3。 我错过了什么?
【问题讨论】: