Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
ba25eab3
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
402
Star
3
Fork
10
代码
文件
提交
分支
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看板
提交
ba25eab3
编写于
4月 17, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(component-instance): emit
上级
b41b9a01
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
132 addition
and
26 deletion
+132
-26
pages.json
pages.json
+28
-22
pages/component-instance/emit-function/child-composition.uvue
...s/component-instance/emit-function/child-composition.uvue
+17
-0
pages/component-instance/emit-function/child-options.uvue
pages/component-instance/emit-function/child-options.uvue
+0
-0
pages/component-instance/emit-function/emit-function-composition.uvue
...ent-instance/emit-function/emit-function-composition.uvue
+37
-0
pages/component-instance/emit-function/emit-function-options.uvue
...mponent-instance/emit-function/emit-function-options.uvue
+1
-1
pages/component-instance/emit-function/emit-function.test.js
pages/component-instance/emit-function/emit-function.test.js
+14
-3
pages/component-instance/force-update/force-update-composition.uvue
...onent-instance/force-update/force-update-composition.uvue
+19
-0
pages/index/index.uvue
pages/index/index.uvue
+16
-0
未找到文件。
pages.json
浏览文件 @
ba25eab3
...
@@ -126,13 +126,13 @@
...
@@ -126,13 +126,13 @@
{
{
"path"
:
"pages/built-in/component/keep-alive/keep-alive-options"
,
"path"
:
"pages/built-in/component/keep-alive/keep-alive-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"keep-alive
(选项式 API)
"
"navigationBarTitleText"
:
"keep-alive
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/keep-alive/keep-alive-composition"
,
"path"
:
"pages/built-in/component/keep-alive/keep-alive-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"keep-alive
(组合式 API)
"
"navigationBarTitleText"
:
"keep-alive
组合式 API
"
}
}
},
},
{
{
...
@@ -280,14 +280,14 @@
...
@@ -280,14 +280,14 @@
{
{
"path"
:
"pages/lifecycle/page/page-composition"
,
"path"
:
"pages/lifecycle/page/page-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"page-lifecycle
(组合式 API)
"
,
"navigationBarTitleText"
:
"page-lifecycle
组合式 API
"
,
"enablePullDownRefresh"
:
true
"enablePullDownRefresh"
:
true
}
}
},
},
{
{
"path"
:
"pages/lifecycle/page/page-options"
,
"path"
:
"pages/lifecycle/page/page-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"page-lifecycle
(选项式 API)
"
,
"navigationBarTitleText"
:
"page-lifecycle
选项式 API
"
,
"enablePullDownRefresh"
:
true
"enablePullDownRefresh"
:
true
}
}
},
},
...
@@ -312,13 +312,13 @@
...
@@ -312,13 +312,13 @@
{
{
"path"
:
"pages/component-instance/refs/refs-options"
,
"path"
:
"pages/component-instance/refs/refs-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"$refs
(选项式 API)
"
"navigationBarTitleText"
:
"$refs
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/component-instance/refs/refs-composition"
,
"path"
:
"pages/component-instance/refs/refs-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"$refs
(组合式 API)
"
"navigationBarTitleText"
:
"$refs
组合式 API
"
}
}
},
},
{
{
...
@@ -334,9 +334,15 @@
...
@@ -334,9 +334,15 @@
}
}
},
},
{
{
"path"
:
"pages/component-instance/emit-function/emit-function"
,
"path"
:
"pages/component-instance/emit-function/emit-function
-options
"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"$emit()"
"navigationBarTitleText"
:
"$emit() 选项式 API"
}
},
{
"path"
:
"pages/component-instance/emit-function/emit-function-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"defineEmits 组合式 API"
}
}
},
},
{
{
...
@@ -414,37 +420,37 @@
...
@@ -414,37 +420,37 @@
{
{
"path"
:
"pages/built-in/component/slots/slots-composition"
,
"path"
:
"pages/built-in/component/slots/slots-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"slots
(组合式 API)
"
"navigationBarTitleText"
:
"slots
组合式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/slots/slots-options"
,
"path"
:
"pages/built-in/component/slots/slots-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"slots
(选项式 API)
"
"navigationBarTitleText"
:
"slots
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/template/template-options"
,
"path"
:
"pages/built-in/component/template/template-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"template
(选项式 API)
"
"navigationBarTitleText"
:
"template
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/template/template-composition"
,
"path"
:
"pages/built-in/component/template/template-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"template
(组合式 API)
"
"navigationBarTitleText"
:
"template
组合式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/template/template-map-style-options"
,
"path"
:
"pages/built-in/component/template/template-map-style-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"template-map-style
(选项式 API)
"
"navigationBarTitleText"
:
"template-map-style
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/template/template-map-style-composition"
,
"path"
:
"pages/built-in/component/template/template-map-style-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"template-map-style
(组合式 API)
"
"navigationBarTitleText"
:
"template-map-style
组合式 API
"
}
}
},
},
{
{
...
@@ -456,13 +462,13 @@
...
@@ -456,13 +462,13 @@
{
{
"path"
:
"pages/built-in/component/component/component-options"
,
"path"
:
"pages/built-in/component/component/component-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"component
(选项式 API)
"
"navigationBarTitleText"
:
"component
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/built-in/component/component/component-composition"
,
"path"
:
"pages/built-in/component/component/component-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"component
(组合式 API)
"
"navigationBarTitleText"
:
"component
组合式 API
"
}
}
},
},
{
{
...
@@ -520,25 +526,25 @@
...
@@ -520,25 +526,25 @@
{
{
"path"
:
"pages/examples/nested-component-communication/nested-component-communication-options"
,
"path"
:
"pages/examples/nested-component-communication/nested-component-communication-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"嵌套组件通信
(选项式 API)
"
"navigationBarTitleText"
:
"嵌套组件通信
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/examples/nested-component-communication/nested-component-communication-composition"
,
"path"
:
"pages/examples/nested-component-communication/nested-component-communication-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"嵌套组件通信
(组合式 API)
"
"navigationBarTitleText"
:
"嵌套组件通信
组合式 API
"
}
}
},
},
{
{
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-options"
,
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式
(选项式 API)
"
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式
选项式 API
"
}
}
},
},
{
{
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition"
,
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式
(组合式 API)
"
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式
组合式 API
"
}
}
},
},
{
{
...
@@ -770,14 +776,14 @@
...
@@ -770,14 +776,14 @@
{
{
"path"
:
"pages/built-in/component/teleport/teleport-options"
,
"path"
:
"pages/built-in/component/teleport/teleport-options"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"teleport
(选项式 API)
"
,
"navigationBarTitleText"
:
"teleport
选项式 API
"
,
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
},
},
{
{
"path"
:
"pages/built-in/component/teleport/teleport-composition"
,
"path"
:
"pages/built-in/component/teleport/teleport-composition"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"teleport
(组合式 API)
"
,
"navigationBarTitleText"
:
"teleport
组合式 API
"
,
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
},
},
...
...
pages/component-instance/emit-function/child-composition.uvue
0 → 100644
浏览文件 @
ba25eab3
<template>
<view>
<button @click="click" class="call-parent-btn">调用父组件事件</button>
</view>
</template>
<script setup lang="uts">
const emit = defineEmits(['callback'])
const click = () => {
emit('callback', `${Date.now()}`)
}
defineExpose({
click
})
</script>
\ No newline at end of file
pages/component-instance/emit-function/child.uvue
→
pages/component-instance/emit-function/child
-options
.uvue
浏览文件 @
ba25eab3
文件已移动
pages/component-instance/emit-function/emit-function-composition.uvue
0 → 100644
浏览文件 @
ba25eab3
<template>
<view class="page">
<view class="row">
<text>子组件传的参数</text>
<text>
{{ value }}
</text>
</view>
<child @callback="callback"></child>
</view>
</template>
<script setup lang="uts">
import child from './child-composition.uvue'
defineOptions({
data() {
return {
value: ''
}
},
methods: {
callback(str: string) {
this.value = str
}
}
})
</script>
<style>
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
pages/component-instance/emit-function/emit-function.uvue
→
pages/component-instance/emit-function/emit-function
-options
.uvue
浏览文件 @
ba25eab3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
</template>
</template>
<script>
<script>
import child from './child.uvue'
import child from './child
-options
.uvue'
export default {
export default {
components: {
components: {
...
...
pages/component-instance/emit-function/emit-function.test.js
浏览文件 @
ba25eab3
const
PAGE_PATH
=
'
/pages/component-instance/emit-function/emit-function
'
const
PAGE_PATH
=
'
/pages/component-instance/emit-function/emit-function-options
'
const
PAGE_COMPOSITION_PATH
=
'
/pages/component-instance/emit-function/emit-function-composition
'
describe
(
'
$emit()
'
,
()
=>
{
describe
(
'
$emit()
'
,
()
=>
{
let
page
let
page
beforeAll
(
async
()
=>
{
it
(
'
$emit() 选项式 API 事件生效
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
waitFor
(
500
)
const
beforeValue
=
await
page
.
data
(
'
value
'
)
const
btn
=
await
page
.
$
(
'
.call-parent-btn
'
)
btn
.
tap
()
const
afterValue
=
await
page
.
data
(
'
value
'
)
expect
(
beforeValue
).
not
.
toBe
(
afterValue
)
})
})
it
(
'
$emit() 事件生效
'
,
async
()
=>
{
it
(
'
$emit() 组合式 API 事件生效
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_COMPOSITION_PATH
)
await
page
.
waitFor
(
500
)
const
beforeValue
=
await
page
.
data
(
'
value
'
)
const
beforeValue
=
await
page
.
data
(
'
value
'
)
const
btn
=
await
page
.
$
(
'
.call-parent-btn
'
)
const
btn
=
await
page
.
$
(
'
.call-parent-btn
'
)
...
...
pages/component-instance/force-update/force-update-composition.uvue
0 → 100644
浏览文件 @
ba25eab3
<template>
<view class="page">
<view class="split-title">$forceUpdate</view>
<text class="uni-common-mt time">Date.now(): {{ Date.now() }}</text>
<button class="uni-common-mt trigger-force-update-btn" type="primary" @click="triggerForceUpdate">trigger $forceUpdate</button>
</view>
</template>
<script setup lang="uts">
const instance = getCurrentInstance()
const triggerForceUpdate = () => {
instance.$.forceUpdate()
}
defineExpose({
triggerForceUpdate
})
</script>
pages/index/index.uvue
浏览文件 @
ba25eab3
...
@@ -248,6 +248,22 @@ export default {
...
@@ -248,6 +248,22 @@ export default {
url: 'refs-composition'
url: 'refs-composition'
}
}
]
]
},
{
id: 'emit-function',
name: '$emit',
children: [
{
id: 'emit-options',
name: '$emit 选项式 API',
url: 'emit-function-options'
},
{
id: 'emit-composition',
name: 'defineEmits 组合式 API',
url: 'emit-function-options'
}
]
}
}
] as Page[]
] as Page[]
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录