Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
bfc5b606
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
401
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看板
提交
bfc5b606
编写于
11月 24, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: dynamic component
上级
4b29097e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
92 addition
and
5 deletion
+92
-5
components/Bar.uvue
components/Bar.uvue
+3
-0
components/Foo.uvue
components/Foo.uvue
+3
-0
pages.json
pages.json
+6
-0
pages/index.uvue
pages/index.uvue
+10
-5
pages/rendering/component/component.test.js
pages/rendering/component/component.test.js
+26
-0
pages/rendering/component/component.uvue
pages/rendering/component/component.uvue
+44
-0
未找到文件。
components/Bar.uvue
0 → 100644
浏览文件 @
bfc5b606
<template>
<text class="component-bar">this is component Bar</text>
</template>
components/Foo.uvue
0 → 100644
浏览文件 @
bfc5b606
<template>
<text class="component-foo">this is component Foo</text>
</template>
\ No newline at end of file
pages.json
浏览文件 @
bfc5b606
...
@@ -248,6 +248,12 @@
...
@@ -248,6 +248,12 @@
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
},
},
{
"path"
:
"pages/rendering/component/component"
,
"style"
:
{
"navigationBarTitleText"
:
"component"
}
},
{
{
"path"
:
"pages/examples/nested-component-communication/nested-component-communication"
,
"path"
:
"pages/examples/nested-component-communication/nested-component-communication"
,
"style"
:
{
"style"
:
{
...
...
pages/index.uvue
浏览文件 @
bfc5b606
...
@@ -215,11 +215,16 @@
...
@@ -215,11 +215,16 @@
url: 'render',
url: 'render',
enable: false,
enable: false,
},
},
{
{
name: 'slots',
name: 'slots',
url: 'slots',
url: 'slots',
enable: true,
enable: true,
},
},
{
name: 'component',
url: 'component',
enable: true,
},
] as PageItem[],
] as PageItem[],
},
},
{
{
...
...
pages/rendering/component/component.test.js
0 → 100644
浏览文件 @
bfc5b606
describe
(
'
/pages/rendering/component/component
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/rendering/component/component
'
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
let
fooList
=
await
page
.
$$
(
'
.component-foo
'
)
expect
(
fooList
.
length
).
toBe
(
2
)
expect
(
await
fooList
[
0
].
text
()).
toBe
(
'
this is component Foo
'
)
expect
(
await
fooList
[
1
].
text
()).
toBe
(
'
this is component Foo
'
)
let
barList
=
await
page
.
$$
(
'
.component-bar
'
)
expect
(
barList
.
length
).
toBe
(
0
)
await
page
.
callMethod
(
'
changeCurrentComponent
'
)
fooList
=
await
page
.
$$
(
'
.component-foo
'
)
expect
(
fooList
.
length
).
toBe
(
0
)
barList
=
await
page
.
$$
(
'
.component-bar
'
)
expect
(
barList
.
length
).
toBe
(
2
)
expect
(
await
barList
[
0
].
text
()).
toBe
(
'
this is component Bar
'
)
expect
(
await
barList
[
1
].
text
()).
toBe
(
'
this is component Bar
'
)
})
});
\ No newline at end of file
pages/rendering/component/component.uvue
0 → 100644
浏览文件 @
bfc5b606
<template>
<view class="container">
<component :is="currentComponentStr" />
<component :is="currentComponentInstance" />
<button @click="changeCurrentComponent">change current component</button>
</view>
</template>
<script lang="uts">
import Foo from '../../../components/Foo.uvue'
import Bar from '../../../components/Bar.uvue'
export default {
components: {
Foo,
Bar
},
data() {
return {
currentComponentStr: 'Foo',
currentComponentInstance: Foo,
}
},
methods: {
changeCurrentComponent() {
if (this.currentComponentStr === 'Foo') {
this.currentComponentStr = 'Bar'
this.currentComponentInstance = Bar
} else {
this.currentComponentStr = 'Foo'
this.currentComponentInstance = Foo
}
}
}
}
</script>
<style>
.item {
display: flex;
flex-direction: row;
margin: 15px;
border: #eee solid 1px;
}
</style>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录