Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于vue3,使用leaflet,弹poput窗的问题。 #11

Open
BYoungDream opened this issue Nov 29, 2022 · 3 comments
Open

关于vue3,使用leaflet,弹poput窗的问题。 #11

BYoungDream opened this issue Nov 29, 2022 · 3 comments

Comments

@BYoungDream
Copy link

您好,我在用vue3,使用leaflet,弹poput,使用自定义的vue3组件,我在尝试过程中发现,不能执行dom操作,不知道你有没有遇到这个问题,请教一下,谢谢!

@aehyok
Copy link
Owner

aehyok commented Nov 30, 2022

兄弟,截图看看

@BYoungDream
Copy link
Author

/**

  • 返回vue组件dom
  • @param component xxx.vue
  • @param props 自定义传递给组件的属性数据
  • @returns {any|VNode} dom id
    */
    const returnVueComponentElement = (component, props = {}) =>{
    let idtxt = "popupid";
    let node = document.getElementById(idtxt);
    if(!node){
    node = document.createElement('div');
    node.id = idtxt;
    document.getElementById('aironemap').appendChild(node);
    }
    let instance = createVNode(component,props);
    render(instance,node);
    return instance.el;
    }

//绑定marker 的click事件
marker.on('click', function () {

        let popuphtml = returnVueComponentElement(Vuecomm);//Vuecomm是一个单独的组件
        var popup = L.popup({'offset':[250,400],'className':'cus-airPopup'}).setLatLng([item.latitude,item.longitude]).setContent(popuphtml);
        mapObj.value.openPopup(popup);

    });

兄弟,你看一下!

@BYoungDream
Copy link
Author

在vue2中,我可以这样实现:如下代码所示

ponitTxt.on('click', function () {
const instance = new Vue(Vuecomm);//Vuecomm是一个单独的组件

        const el = instance.$mount().$el;
        var popup = L.popup({'offset':[250,400],'className':'cus-airPopup'}).setLatLng([23.0383,113.19209]).setContent(el);
        map.openPopup(popup);

  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants