leaflet中创建popup弹窗,如何使用vue组件
- 创建vue组件TestModal.vue,接收testData参数,发出close事件
<template>
<div></div>
</template>
<script>
export default {
props: {
testData: {
type: Obj,
default: () => {
return {};
},
},
},
emits: ["close"],
setup(props, { emit }) {
const onClickHandle = () => {
emit("close", {});
};
},
};
</script>
<style>
</style>
- 创建popup
import TestModal from './TestModal.vue'
const TestModalVue = Vue.extend(TestModal);
const createPopUp = info => {
let vm = new TestModalVue({
propsData: {
testData: {},
testData2: {},
...
},
});
vm.$on('close', obj => {
});
vm.$mount();
let htmlDom = vm.$el;
L.popup({
})
.setLatLng([lat,lon])
.setContent(htmlDom as HTMLElement)
.openOn(map);
};