|
@@ -1,18 +1,29 @@
|
|
|
<script setup>
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
-import { useRoute } from "vue-router";
|
|
|
+import { ref, watch } from "vue";
|
|
|
+import { useRoute, onBeforeRouteLeave } from "vue-router";
|
|
|
|
|
|
const route = useRoute();
|
|
|
-const imgBg = ref('');
|
|
|
-onMounted(() => {
|
|
|
- imgBg.value = route.query.imgBg;
|
|
|
+const imgBg = ref("");
|
|
|
|
|
|
+watch(
|
|
|
+ () => route.query.imgBg,
|
|
|
+ (e) => {
|
|
|
+ if (e) {
|
|
|
+ // 刷新收藏
|
|
|
+ imgBg.value = route.query.imgBg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+
|
|
|
+onBeforeRouteLeave(() => {
|
|
|
+ imgBg.value = "";
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="container-disseminate">
|
|
|
- <img :src="imgBg" alt="" />
|
|
|
+ <img v-if="imgBg" :src="imgBg" alt="" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|