路由结构 router children 会统计2遍
sce9966 opened this issue · 2 comments
sce9966 commented
const router = new VueRouter({ routes: [ { path: "/", name: "HOME", component: index, children:[ { path: "/started", name: "STARTED", component: Started }, { path: "/custom-events", name: "CUSTOM_EVENTS", component: CustomEvents }, { path: "/track-view", name: "TRACK_VIEW", component: TrackView, meta: { keepAlive: true } }, { path: "/block-show", name: "BLOCK_SHOW", component: BlockShow }, ] }, { path: "*", redirect: "/" } ] });
l-hammer commented
@hqy1204 确实会统计两次,这里把顶层组件也当作一个页面。如果无需统计可通过以下方法过滤:
<!-- home.vue -->
<template>
<router-view></router-view>
</template>
<script>
export default {
data: () => ({
needTrack: false // 关闭当前页埋点
})
}
</script>
/** track.js */
export default {
UVPV({ needTrack = true }) {
// 过滤嵌套的上层路由
if (!needTrack) return;
trackAction("id", params);
}
};