美文网首页
离开钩子beforeRouteLeave

离开钩子beforeRouteLeave

作者: royluck | 来源:发表于2019-03-11 11:00 被阅读0次

注意记得加next(),要不然页面刷新
场景:[图片上传中...(image.png-be64c-1552273101501-0)]

beforeRouteLeave (to, from, next) {
            instance.close();   // 监控离开钩子,关闭预览vant预览弹窗
            next();  // 记得加这个!!!!
        },
// 更新导购助力活动的推广海报
            let instance = null
            refreshPoster(url) {
                return new Promise(resolve => {
                    const params = {
                        token: localStorage.token,
                        hd_id: this.id,  //     活动id
                        poster_url: url //  上传至腾讯云的海报url
                    }
                    Http.ai['activity/collection/updateSalesmanPoster'](params)
                    (e => {
                        if(e.code == 0){
                            let mediaID = e.data.media_id
                            this.loadingFlag = false
                            resolve(mediaID)
                            instance = ImagePreview({
                                images: [
                                    url
                                ],
                                className: 'down-image',
                                showIndex: false,
                                showIndicators: false,
                                startPosition: 1
                            });
                        }else {
                            Toast(e.msg)
                        }
                    })
                })
            },

image.png

相关文章

网友评论

      本文标题:离开钩子beforeRouteLeave

      本文链接:https://www.haomeiwen.com/subject/fgsvpqtx.html