小编Ami*_*ore的帖子

在mapbox gl js中的图层上注册点击事件时如何处理事件冒泡

如何停止层单击事件的事件传播。

mapBox.on('click', layerId, function (e) {
        console.log(e);
        //e.stopPropagation(); which is not working 
        //e.originalEvent.stopPropagation(); which is not working 
        var popupHtml = getPopupHtmlWrapper(e.features[0]);
        new mapboxgl.Popup({closeButton:false})
                .setLngLat(e.lngLat)
                .setHTML(popupHtml)
                .addTo(mapBox);
    });
Run Code Online (Sandbox Code Playgroud)

mapbox-gl-js

6
推荐指数
4
解决办法
914
查看次数

在 vue 中,如何检查父组件是否订阅了子组件发出的事件?

我有一个组件,有时被用作父组件的子组件,有时它没有任何父组件。

该组件发出一个特定的事件,该事件要么被父级捕获(如果订阅),要么我想由该组件本身处理它。

那么在运行时,我如何以编程方式检查

if (someone is listening to the event){
    let them catch and handle it
}else {
    let's handle it by our own
}
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-component vuejs2

4
推荐指数
1
解决办法
3217
查看次数

标签 统计

javascript ×1

mapbox-gl-js ×1

vue-component ×1

vue.js ×1

vuejs2 ×1