-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
Should we do this
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ export default defineComponent({ | |
}) | ||
return { | ||
exposedMethod1, | ||
returnedState, | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
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) => { | ||
Check failure on line 55 in tests/components/DefineExposeBundled.ts GitHub Actions / build (18)
Check failure on line 55 in tests/components/DefineExposeBundled.ts GitHub Actions / build (18)
Check failure on line 55 in tests/components/DefineExposeBundled.ts GitHub Actions / build (20)
Check failure on line 55 in tests/components/DefineExposeBundled.ts GitHub Actions / build (20)
Check failure on line 55 in tests/components/DefineExposeBundled.ts GitHub Actions / build (22)
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineComponent, h } from 'vue' | ||
|
||
export default defineComponent({ | ||
name: 'FindComponentExposeRenderFunction', | ||
props: { | ||
someProp: String | ||
}, | ||
setup(_, { expose }) { | ||
const exposedFn = () => { | ||
return 'exposedFnReturn' | ||
} | ||
|
||
expose({ | ||
exposedFn | ||
}) | ||
|
||
return () => { | ||
return h('div', 'Example') | ||
} | ||
} | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<template> | ||
<div>Example</div> | ||
</template> | ||
|
||
<script setup> | ||
const props = defineProps({ | ||
someProp: String, | ||
}); | ||
const exposedFn = () => { | ||
return 'exposedFnReturn'; | ||
}; | ||
defineExpose({ | ||
exposedFn, | ||
}); | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { openBlock, createElementBlock } from 'vue' | ||
const _sfc_main = { | ||
__name: 'FindComponentExposeScriptSetupBundled', | ||
props: { | ||
someProp: String | ||
}, | ||
setup(__props, { expose: __expose }) { | ||
Check failure on line 7 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (18)
Check failure on line 7 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (18)
Check failure on line 7 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (20)
Check failure on line 7 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (20)
Check failure on line 7 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (22)
|
||
const exposedFn = () => { | ||
return 'exposedFnReturn' | ||
} | ||
__expose({ | ||
exposedFn | ||
}) | ||
return (_ctx, _cache) => { | ||
Check failure on line 14 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (18)
Check failure on line 14 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (18)
Check failure on line 14 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (20)
Check failure on line 14 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (20)
Check failure on line 14 in tests/components/FindComponentExposeScriptSetupBundled.ts GitHub Actions / build (22)
|
||
return openBlock(), createElementBlock('div', null, 'Example') | ||
} | ||
} | ||
} | ||
export default _sfc_main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<div>Example</div> | ||
</template> | ||
|
||
<script> | ||
import { defineComponent } from 'vue'; | ||
export default defineComponent({ | ||
name: 'FindComponentExposeTemplate', | ||
props: { | ||
someProp: String, | ||
}, | ||
setup(_, { expose }) { | ||
const exposedFn = () => { | ||
return 'exposedFnReturn'; | ||
}; | ||
expose({ | ||
exposedFn, | ||
}); | ||
return { | ||
oopsy: 1 | ||
}; | ||
} | ||
}) | ||
</script> | ||
|