简体   繁体   中英

how to invalidateSize leaflet map in vue js?

i'm using vue-nav-tabs plugin, and using @tab-change="handleTabChange" event for tab changes.

i'm using tabs in parent component

methods: {
    handleTabChange() {
        this.$refs.map.invalidateSize();
    }
}

this is Map(child component)

methods: {
     invalidateSize() {
                this.map.invalidateSize(true);
                console.log(true)
     }
}

this invalidateSize method run successfully but map doesn't re render.

what should i do?

The tab-change event of Vue-tabs plugin is emitted synchronously with the actual operation to perform the tab navigation. Therefore most likely the new tab has not appeared yet when the event fires.

Using a short timeout after the event should give some time for the tab to appear, and invalidateSize will then be able to get the correct map container dimensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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