Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
fa5dc483
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
371
Star
3
Fork
8
代码
文件
提交
分支
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看板
提交
fa5dc483
编写于
10个月前
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: example
上级
40281220
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
240 addition
and
94 deletion
+240
-94
pages.json
pages.json
+16
-4
pages/examples/nested-component-communication/components/child.uvue
...ples/nested-component-communication/components/child.uvue
+29
-28
pages/examples/nested-component-communication/components/grandChild.uvue
...nested-component-communication/components/grandChild.uvue
+31
-31
pages/examples/nested-component-communication/nested-component-communication-composition.uvue
...unication/nested-component-communication-composition.uvue
+21
-0
pages/examples/nested-component-communication/nested-component-communication-options.uvue
...communication/nested-component-communication-options.uvue
+30
-0
pages/examples/nested-component-communication/nested-component-communication.test.js
...nent-communication/nested-component-communication.test.js
+46
-0
pages/examples/nested-component-communication/nested-component-communication.uvue
...mponent-communication/nested-component-communication.uvue
+0
-27
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition.uvue
...t-custom-child-component-root-node-class-composition.uvue
+20
-0
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-options.uvue
...s/set-custom-child-component-root-node-class-options.uvue
+0
-0
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class.test.js
...-class/set-custom-child-component-root-node-class.test.js
+9
-4
pages/index/index.uvue
pages/index/index.uvue
+38
-0
未找到文件。
pages.json
浏览文件 @
fa5dc483
...
...
@@ -506,15 +506,27 @@
}
},
{
"path"
:
"pages/examples/nested-component-communication/nested-component-communication"
,
"path"
:
"pages/examples/nested-component-communication/nested-component-communication
-options
"
,
"style"
:
{
"navigationBarTitleText"
:
"嵌套组件通信"
"navigationBarTitleText"
:
"嵌套组件通信
(选项式)
"
}
},
{
"path"
:
"pages/examples/
set-custom-child-component-root-node-class/set-custom-child-component-root-node-class
"
,
"path"
:
"pages/examples/
nested-component-communication/nested-component-communication-composition
"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式"
"navigationBarTitleText"
:
"嵌套组件通信(组合式)"
}
},
{
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-options"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式(选项式)"
}
},
{
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式(组合式)"
}
},
{
...
...
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/components/child.uvue
浏览文件 @
fa5dc483
<template>
<view class="child">
子组件: {{ msg }}
<grand-child></grand-child>
</view>
</template>
<script>
import grandChild from './grandChild.uvue'
import {
state
} from '@/store/index.uts'
export default {
components: {
grandChild
},
computed: {
msg(): number {
return state.componentMsg
}
}
}
</script>
<style>
.child {
margin-top: 10px;
}
</style>
\ No newline at end of file
<template>
<view class="child">
<view class="flex-row">
子组件:
<text class="child-msg">{{ msg }}</text>
</view>
<grand-child></grand-child>
</view>
</template>
<script>
import grandChild from './grandChild.uvue'
import { state } from '@/store/index.uts'
export default {
components: {
grandChild
},
computed: {
msg(): number {
return state.componentMsg
}
}
}
</script>
<style>
.child {
margin-top: 10px;
}
</style>
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/components/grandChild.uvue
浏览文件 @
fa5dc483
<template>
<view class="child">
孙组件: {{ msg }}
<button @click="change">孙组件清空数据</button>
</view>
</template>
<script>
import {
state,
setComponentMsg
} from '@/store/index.uts'
export default {
computed: {
msg(): number {
return state.componentMsg
}
},
methods: {
change() {
setComponentMsg(0)
}
}
}
</script>
<style>
.child {
margin-top: 10px;
}
</style>
\ No newline at end of file
<template>
<view class="child">
<view class="flex-row">
孙组件:
<text class="grandchild-msg">{{ msg }}</text>
</view>
<button class="grandchild-btn" @click="change">孙组件清空数据</button>
</view>
</template>
<script>
import { state, setComponentMsg } from '@/store/index.uts'
export default {
computed: {
msg(): number {
return state.componentMsg
}
},
methods: {
change() {
setComponentMsg(0)
}
}
}
</script>
<style>
.child {
margin-top: 10px;
}
</style>
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/nested-component-communication-composition.uvue
0 → 100644
浏览文件 @
fa5dc483
<template>
<view class="page">
<view class="flex-row">
父组件:
<text class="parent-msg">{{ msg }}</text>
</view>
<button class="parent-btn" @click="change">父组件改变数据</button>
<child />
</view>
</template>
<script setup lang="uts">
import child from './components/child.uvue'
import { setComponentMsg, state } from '@/store/index.uts'
const msg = computed<number>((): number => state.componentMsg)
const change = () => {
setComponentMsg(state.componentMsg + 1)
}
</script>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/nested-component-communication-options.uvue
0 → 100644
浏览文件 @
fa5dc483
<template>
<view class="page">
<view class="flex-row">
父组件:
<text class="parent-msg">{{ msg }}</text>
</view>
<button class="parent-btn" @click="change">父组件改变数据</button>
<child></child>
</view>
</template>
<script>
import child from './components/child.uvue'
import { setComponentMsg, state } from '@/store/index.uts'
export default {
components: {
child
},
computed: {
msg(): number {
return state.componentMsg
}
},
methods: {
change() {
setComponentMsg(state.componentMsg + 1)
}
}
}
</script>
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/nested-component-communication.test.js
0 → 100644
浏览文件 @
fa5dc483
const
PAGE_OPTIONS
=
'
/pages/examples/nested-component-communication/nested-component-communication-options
'
const
PAGE_COMPOSITION
=
'
/pages/examples/nested-component-communication/nested-component-communication-composition
'
describe
(
'
built-in/component
'
,
()
=>
{
let
page
const
test
=
async
()
=>
{
await
page
.
waitFor
(
'
view
'
)
expect
.
assertions
(
12
)
const
parentMsgElement
=
await
page
.
$
(
'
.parent-msg
'
)
const
childMsgElement
=
await
page
.
$
(
'
.child-msg
'
)
const
grandChildElement
=
await
page
.
$
(
'
.grandchild-msg
'
)
const
parentBtn
=
await
page
.
$
(
'
.parent-btn
'
)
const
grandChildBtn
=
await
page
.
$
(
'
.grandchild-btn
'
)
expect
(
await
parentMsgElement
.
text
()).
toEqual
(
'
0
'
)
expect
(
await
childMsgElement
.
text
()).
toEqual
(
'
0
'
)
expect
(
await
grandChildElement
.
text
()).
toEqual
(
'
0
'
)
await
parentBtn
.
tap
()
expect
(
await
parentMsgElement
.
text
()).
toEqual
(
'
1
'
)
expect
(
await
childMsgElement
.
text
()).
toEqual
(
'
1
'
)
expect
(
await
grandChildElement
.
text
()).
toEqual
(
'
1
'
)
await
parentBtn
.
tap
()
expect
(
await
parentMsgElement
.
text
()).
toEqual
(
'
2
'
)
expect
(
await
childMsgElement
.
text
()).
toEqual
(
'
2
'
)
expect
(
await
grandChildElement
.
text
()).
toEqual
(
'
2
'
)
await
grandChildBtn
.
tap
()
expect
(
await
parentMsgElement
.
text
()).
toEqual
(
'
0
'
)
expect
(
await
childMsgElement
.
text
()).
toEqual
(
'
0
'
)
expect
(
await
grandChildElement
.
text
()).
toEqual
(
'
0
'
)
}
it
(
'
nested-component-communication Options API
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_OPTIONS
)
await
test
()
})
it
(
'
nested-component-communication Composition API
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_COMPOSITION
)
await
test
()
})
})
This diff is collapsed.
Click to expand it.
pages/examples/nested-component-communication/nested-component-communication.uvue
已删除
100644 → 0
浏览文件 @
40281220
<template>
<view class="page">
父组件: {{ msg }}
<button @click="change">父组件改变数据</button>
<child></child>
</view>
</template>
<script>
import child from './components/child.uvue'
import { setComponentMsg, state } from '@/store/index.uts'
export default {
components: {
child
},
computed: {
msg() : number {
return state.componentMsg
}
},
methods: {
change() {
setComponentMsg(state.componentMsg + 1)
}
}
}
</script>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition.uvue
0 → 100644
浏览文件 @
fa5dc483
<template>
<view>
<button class="btn-page bg-green">button in parent page</button>
<Child />
</view>
</template>
<script setup lang="uts">
import Child from './child.uvue'
</script>
<style>
.btn-page {
width: 280px;
color: rgb(209, 51, 51);
}
.bg-green {
background-color: rgb(105, 154, 105);
}
</style>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class.uvue
→
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class
-options
.uvue
浏览文件 @
fa5dc483
文件已移动
This diff is collapsed.
Click to expand it.
pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class.test.js
浏览文件 @
fa5dc483
const
PAGE_PATH
=
'
/pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class
'
const
PAGE_PATH
=
'
/pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-options
'
const
PAGE_PATH_COMPOSITION
=
'
/pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class-composition
'
describe
(
'
自定义组件中使用 class 定制另一个自定义组件根节点样式
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
it
(
'
set-custom-child-component-root-node-class-options Screenshot
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
it
(
'
screenshot
'
,
async
()
=>
{
it
(
'
set-custom-child-component-root-node-class-options Screenshot
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH_COMPOSITION
)
await
page
.
waitFor
(
'
view
'
)
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
...
...
This diff is collapsed.
Click to expand it.
pages/index/index.uvue
浏览文件 @
fa5dc483
...
...
@@ -348,6 +348,44 @@ export default {
url: 'unrecognized-component/unrecognized-component'
}
] as Page[]
},
{
id: 'examples',
name: '示例',
pages: [
{
id: 'nested-component-communication',
name: '嵌套组件通讯',
children: [
{
id: 'nested-component-communication-options',
name: '选项式',
url: 'nested-component-communication-options'
},
{
id: 'nested-component-communication-composition',
name: '组合式',
url: 'nested-component-communication-composition'
}
]
},
{
id: 'set-custom-child-component-root-node-class',
name: '自定义组件中使用 class 定制另一个自定义组件根节点样式',
children: [
{
id: 'set-custom-child-component-root-node-class-options',
name: '选项式',
url: 'set-custom-child-component-root-node-class-options'
},
{
id: 'set-custom-child-component-root-node-class-composition',
name: '组合式',
url: 'set-custom-child-component-root-node-class-composition'
}
]
}
] as Page[]
}
] as Menu[]
}
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录