提交 ba324ee1 编写于 作者: 雪洛's avatar 雪洛

test: 增加使用$callMethod调用defineExpose内方法的测试例

上级 6ed84ed1
......@@ -289,6 +289,12 @@
"navigationBarTitleText": "call-method-easycom-uni-modules"
}
},
{
"path": "pages/component-instance/methods/call-method-define-expose",
"style": {
"navigationBarTitleText": "call-method-define-expose"
}
},
{
"path": "pages/component-instance/methods/call-method-other",
"style": {
......
const PAGE_PATH = '/pages/component-instance/methods/call-method-define-expose'
describe('call-method-define-expose', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500)
})
it('callMethodTest', async () => {
const result = await page.callMethod('callMethod')
expect(result).toBe(`hello call-method-define-expose`)
})
})
\ No newline at end of file
<template>
<view>
<component-define-expose ref="comp"></component-define-expose>
</view>
</template>
<script>
// 非easycom组件需import引用组件 component1.uvue
import ComponentDefineExpose from './component-define-expose.uvue'
export default {
components: {
ComponentDefineExpose
},
data() {
return {
component: null as ComponentPublicInstance | null
}
},
onReady() {
this.component = this.$refs['comp'] as ComponentPublicInstance;
},
methods: {
callMethod() {
return this.component!.$callMethod('test', 'call-method-define-expose')
}
}
}
</script>
\ No newline at end of file
<template>
<view></view>
</template>
<script setup>
function test(name: string) {
return `hello ${name}`
}
defineExpose({
test
})
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册