Skip to content

Commit 2adaef6

Browse files
committed
fix production build preference toggle reactivity
1 parent e20ac01 commit 2adaef6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/examples/ExampleRepl.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const store = new ReplStore({
1111
const preferComposition = inject('prefer-composition') as Ref<boolean>
1212
const preferSFC = inject('prefer-sfc') as Ref<boolean>
1313
14-
window.addEventListener('hashchange', updateExample)
1514
watchEffect(updateExample)
15+
window.addEventListener('hashchange', updateExample)
1616
1717
/**
1818
* We perform some runtime logic to transform source files into different
@@ -21,17 +21,17 @@ watchEffect(updateExample)
2121
* - plain HTML vs. SFCs
2222
*/
2323
function updateExample() {
24-
const hash = ___location.hash.slice(1)
25-
if (data.hasOwnProperty(hash)) {
26-
store.setFiles(
27-
preferSFC.value
28-
? resolveSFCExample(data[hash])
29-
: resolveNoBuildExample(data[hash]),
30-
preferSFC.value ? 'App.vue' : 'index.html'
31-
)
32-
} else if (!hash) {
33-
___location.hash = '#markdown'
24+
let hash = ___location.hash.slice(1)
25+
if (!data.hasOwnProperty(hash)) {
26+
hash = 'markdown'
27+
___location.hash = `#${hash}`
3428
}
29+
store.setFiles(
30+
preferSFC.value
31+
? resolveSFCExample(data[hash])
32+
: resolveNoBuildExample(data[hash]),
33+
preferSFC.value ? 'App.vue' : 'index.html'
34+
)
3535
}
3636
3737
type ExampleData = {

0 commit comments

Comments
 (0)