Skip to content

Commit 25f049c

Browse files
committed
fix(guide): [guide] fix guide displaying after jumping to other pages
1 parent 3920df1 commit 25f049c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/renderless/src/guide/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export const mounted =
6262
}
6363
}
6464

65+
export const beforeUnmount = (state) => () => {
66+
state.tour.hide()
67+
}
68+
6569
const getItemCopy = (props, tour, result) => {
6670
const { domData } = props
6771

packages/renderless/src/guide/vue.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import { createShepherd, mounted } from './index'
1+
import { createShepherd, mounted, beforeUnmount } from './index'
22

33
export const api = ['state']
44

5-
export const renderless = (props, { reactive, onMounted, watch }, { designConfig }, { Shepherd, offset }) => {
5+
export const renderless = (
6+
props,
7+
{ reactive, onMounted, onBeforeUnmount, watch },
8+
{ designConfig },
9+
{ Shepherd, offset }
10+
) => {
611
const state = reactive({
712
tour: null,
813
tour1: null,
@@ -25,11 +30,14 @@ export const renderless = (props, { reactive, onMounted, watch }, { designConfig
2530

2631
const api = {
2732
...baseApi,
28-
mounted: mounted({ state, api: baseApi })
33+
mounted: mounted({ state, api: baseApi }),
34+
beforeUnmount: beforeUnmount(state)
2935
}
3036

3137
watch(() => props.showStep, api.createShepherd)
3238

3339
onMounted(api.mounted)
40+
onBeforeUnmount(api.beforeUnmount)
41+
3442
return api
3543
}

0 commit comments

Comments
 (0)