Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
c93d4f13
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
350
Star
2
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c93d4f13
编写于
9月 26, 2024
作者:
F
fxy060608
提交者:
DCloud-WZF
9月 29, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 添加 自定义easycom规则组件类型测试 #9386
上级
7060f33b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
3 deletion
+57
-3
components/custom-call-easy-method.uvue
components/custom-call-easy-method.uvue
+19
-0
pages.json
pages.json
+5
-0
pages/component-instance/methods/call-method-easycom-composition.uvue
...ent-instance/methods/call-method-easycom-composition.uvue
+15
-1
pages/component-instance/methods/call-method-easycom-options.uvue
...mponent-instance/methods/call-method-easycom-options.uvue
+14
-2
pages/component-instance/methods/call-method-easycom.test.js
pages/component-instance/methods/call-method-easycom.test.js
+4
-0
未找到文件。
components/custom-call-easy-method.uvue
0 → 100644
浏览文件 @
c93d4f13
<template>
<view>{{result}}</view>
</template>
<script>
export default {
data() {
return {
result: ''
}
},
methods: {
foo() : string {
this.result = "custom foo"
return this.result
}
}
}
</script>
\ No newline at end of file
pages.json
浏览文件 @
c93d4f13
...
...
@@ -902,6 +902,11 @@
"navigationBarBackgroundColor"
:
"#007AFF"
}
},
"easycom"
:
{
"custom"
:
{
"custom-(.*)"
:
"@/components/custom-$1.uvue"
}
},
"uniIdRouter"
:
{},
"condition"
:
{
"current"
:
0
,
...
...
pages/component-instance/methods/call-method-easycom-composition.uvue
浏览文件 @
c93d4f13
<template>
<view>
<call-easy-method ref="callEasyMethod1"></call-easy-method>
<custom-call-easy-method ref="customCallEasyMethod1"></custom-call-easy-method>
</view>
</template>
<script setup lang="uts">
const callEasyMethod1 = ref<CallEasyMethodComponentPublicInstance | null>(null)
const customCallEasyMethod1 = ref<CustomCallEasyMethodComponentPublicInstance | null>(null)
const callMethod = () => {
// 调用组件的 foo 方法
customCallEasyMethod1.value?.foo?.()
}
const callMethod1 = () => {
// 调用组件的 foo1 方法
...
...
@@ -40,6 +47,11 @@ const callMethodTest = (text: string): string | null => {
return result
}
const callCustomMethodTest = (): string | null => {
const result = customCallEasyMethod1.value?.foo?.() as string
return result
}
const delay = (): Promise<string> =>
new Promise((resolve, _) => {
setTimeout(() => {
...
...
@@ -48,6 +60,7 @@ const delay = (): Promise<string> =>
})
const call = async (): Promise<void> => {
callMethod()
callMethod1()
await delay()
callMethod2()
...
...
@@ -64,6 +77,7 @@ onReady(() => {
})
defineExpose({
callMethodTest
callMethodTest,
callCustomMethodTest
})
</script>
\ No newline at end of file
pages/component-instance/methods/call-method-easycom-options.uvue
浏览文件 @
c93d4f13
<template>
<view>
<call-easy-method ref="callEasyMethod1"></call-easy-method>
<custom-call-easy-method ref="customCallEasyMethod1"></custom-call-easy-method>
</view>
</template>
...
...
@@ -15,16 +16,19 @@ const delay = (): Promise<string> =>
export default {
data() {
return {
callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null
callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null,
customCallEasyMethod1: null as CustomCallEasyMethodComponentPublicInstance | null,
}
},
onReady() {
// 通过组件 ref 属性获取组件实例, 组件标签名首字母大写,驼峰+ComponentPublicInstance
this.callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodComponentPublicInstance
this.customCallEasyMethod1 = this.$refs['customCallEasyMethod1'] as CustomCallEasyMethodComponentPublicInstance
this.call()
},
methods: {
async call(): Promise<void> {
this.callCustomMethod()
this.callMethod1()
await delay()
this.callMethod2()
...
...
@@ -61,7 +65,15 @@ export default {
callMethodTest(text: string): string | null {
const result = this.callEasyMethod1?.foo5?.(text) as string
return result
}
},
callCustomMethod() {
// 调用组件的 foo 方法
this.customCallEasyMethod1?.foo?.()
},
callCustomMethodTest(): string | null {
const result = this.customCallEasyMethod1?.foo?.() as string
return result
},
}
}
</script>
\ No newline at end of file
pages/component-instance/methods/call-method-easycom.test.js
浏览文件 @
c93d4f13
...
...
@@ -10,6 +10,8 @@ describe('call-method-easycom', () => {
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
const
customResult
=
await
page
.
callMethod
(
'
callCustomMethodTest
'
)
expect
(
customResult
).
toBe
(
'
custom foo
'
)
})
it
(
'
callMethodTest Composition API
'
,
async
()
=>
{
...
...
@@ -18,5 +20,7 @@ describe('call-method-easycom', () => {
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
const
customResult
=
await
page
.
callMethod
(
'
callCustomMethodTest
'
)
expect
(
customResult
).
toBe
(
'
custom foo
'
)
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录