From 5c501a048a6282b8b6f9335dc50e376ea1685cd3 Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Fri, 5 Aug 2022 17:54:28 +0800 Subject: [PATCH] update --- src/layout/components/AppMain.vue | 16 ++++++++++++++++ src/router/index.js | 10 ---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue index 7a54a74..0cf6bc6 100644 --- a/src/layout/components/AppMain.vue +++ b/src/layout/components/AppMain.vue @@ -25,6 +25,22 @@ export default { }, key() { return this.$route.path + }, + watch: { + '$route.path': { + handler: function() { + // define ads element + const ads = document.getElementById('ww-container') + // ad parent node + const prn = ads.parentNode + // lets clone ads block + const cln = ads.cloneNode(true) + // remove the current ads block completely + prn.removeChild(ads) + // append a newly cloned one + prn.appendChild(cln) + } + } } } } diff --git a/src/router/index.js b/src/router/index.js index 894600a..874ec0f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -20,16 +20,6 @@ router.beforeEach((to, from, next) => { hm.src = 'https://hm.baidu.com/hm.js?300a24a5326d0e7a0ff1b14c4e8d9056' const s = document.getElementsByTagName('script')[0] s.parentNode.insertBefore(hm, s) - // define ads element - const ads = document.getElementById('ww-container') - // ad parent node - const prn = ads.parentNode - // lets clone ads block - const cln = ads.cloneNode(true) - // remove the current ads block completely - prn.removeChild(ads) - // append a newly cloned one - prn.appendChild(cln) })() }, 0) if (to.meta.title) {