-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathDefineExposeBundled.ts
82 lines (82 loc) · 1.85 KB
/
DefineExposeBundled.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// @ts-ignore
import {
defineComponent,
ref,
openBlock,
createElementBlock,
Fragment,
createElementVNode,
toDisplayString
} from 'vue'
const exposedState1 = 'exposedState1'
const exposedState2 = 'exposedState2'
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: 'Hello'
},
__name: 'DefineExposeScriptSetup',
setup(__props, { expose: __expose }) {
const exposedState2Getter = () => {
return exposedState2
}
const exposedRef = ref('exposedRef')
const exposedRefGetter = () => {
return exposedRef.value
}
const exposedMethod1 = () => {
return 'result of exposedMethod1'
}
const exposedMethod2 = () => {
return 'result of exposedMethod2'
}
const refNonExposed = ref('refNonExposed')
const refNonExposedGetter = () => {
return refNonExposed.value
}
const count = ref(0)
const inc = () => {
count.value++
}
const resetCount = () => {
count.value = 0
}
__expose({
exposeObjectLiteral: 'exposeObjectLiteral',
exposedState1,
exposedState2Alias: exposedState2,
exposedState2Getter,
exposedRef,
exposedRefGetter,
exposedMethod1,
exposedMethod2Alias: exposedMethod2,
count,
resetCount,
refNonExposedGetter
})
return (_ctx, _cache) => {
return (
openBlock(),
createElementBlock(
Fragment,
null,
[
createElementVNode(
'button',
{ onClick: inc },
toDisplayString(count.value),
1
),
createElementVNode(
'div',
{ 'force-expose': exposedMethod1 },
toDisplayString(refNonExposed.value),
1
)
],
64
)
)
}
}
})
export default _sfc_main