Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
71b7504b
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看板
提交
71b7504b
编写于
1月 17, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 调整 provide 错误示例
上级
caa20390
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
71 deletion
+1
-71
pages/composition/provide/component-for-inject-1.uvue
pages/composition/provide/component-for-inject-1.uvue
+0
-23
pages/composition/provide/provide.test.js
pages/composition/provide/provide.test.js
+1
-39
pages/composition/provide/provide.uvue
pages/composition/provide/provide.uvue
+0
-9
未找到文件。
pages/composition/provide/component-for-inject-1.uvue
浏览文件 @
71b7504b
<template>
<template>
<view>
<view>
<text class="uni-common-mt bold">component for inject 1</text>
<text class="uni-common-mt bold">component for inject 1</text>
<text class="uni-common-mt provide-page-title"
>providePageTitle: {{ providePageTitle }}</text
>
<text class="uni-common-mt alias-provide-page-title"
<text class="uni-common-mt alias-provide-page-title"
>aliasProvidePageTitle: {{ aliasProvidePageTitle }}</text
>aliasProvidePageTitle: {{ aliasProvidePageTitle }}</text
>
>
<text class="uni-common-mt computed-title"
>computedTitle: {{ computedTitle }}</text
>
<text class="uni-common-mt provide-data-obj-title"
>provideDataObj.title: {{ provideDataObj['title'] }}</text
>
<text class="uni-common-mt provide-data-obj-content"
>provideDataObj.content: {{ provideDataObj['content'] }}</text
>
<text class="uni-common-mt provide-page-str"
<text class="uni-common-mt provide-page-str"
>providePageStr: {{ providePageStr }}</text
>providePageStr: {{ providePageStr }}</text
>
>
...
@@ -57,22 +45,11 @@
...
@@ -57,22 +45,11 @@
<script lang="uts">
<script lang="uts">
export default {
export default {
inject: {
inject: {
providePageTitle: {
type: String,
default: 'default provide page title'
},
aliasProvidePageTitle: {
aliasProvidePageTitle: {
type: String,
type: String,
from: 'providePageTitle',
from: 'providePageTitle',
default: 'default alias provide page title'
default: 'default alias provide page title'
},
},
computedTitle: {
type: String,
default: 'default computed title'
},
provideDataObj: {
type: Object as PropType<UTSJSONObject>,
},
providePageStr: {
providePageStr: {
type: String,
type: String,
default: 'default provide page str'
default: 'default provide page str'
...
...
pages/composition/provide/provide.test.js
浏览文件 @
71b7504b
...
@@ -6,49 +6,11 @@ describe('字面量方式创建 provide', () => {
...
@@ -6,49 +6,11 @@ describe('字面量方式创建 provide', () => {
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
waitFor
(
'
view
'
)
})
})
it
(
'
variable
'
,
async
()
=>
{
const
providePageTitleEl
=
await
page
.
$
(
'
.provide-page-title
'
)
const
providePageTitleText
=
await
providePageTitleEl
.
text
()
expect
(
providePageTitleText
).
toBe
(
'
providePageTitle: 字面量方式定义 provide page title
'
)
})
it
(
'
alias
'
,
async
()
=>
{
it
(
'
alias
'
,
async
()
=>
{
const
aliasProvidePageTitleEl
=
await
page
.
$
(
'
.alias-provide-page-title
'
)
const
aliasProvidePageTitleEl
=
await
page
.
$
(
'
.alias-provide-page-title
'
)
const
aliasProvidePageTitleText
=
await
aliasProvidePageTitleEl
.
text
()
const
aliasProvidePageTitleText
=
await
aliasProvidePageTitleEl
.
text
()
expect
(
aliasProvidePageTitleText
).
toBe
(
expect
(
aliasProvidePageTitleText
).
toBe
(
'
aliasProvidePageTitle: 字面量方式定义 provide page title
'
'
aliasProvidePageTitle: default alias provide page title
'
)
})
it
(
'
reactive data
'
,
async
()
=>
{
const
computedTitleEl
=
await
page
.
$
(
'
.computed-title
'
)
let
computedTitleText
=
await
computedTitleEl
.
text
()
expect
(
computedTitleText
).
toBe
(
'
computedTitle: 字面量方式定义 provide page title
'
)
const
provideDataObjTitleEl
=
await
page
.
$
(
'
.provide-data-obj-title
'
)
let
provideDataObjTitleText
=
await
provideDataObjTitleEl
.
text
()
expect
(
provideDataObjTitleText
).
toBe
(
'
provideDataObj.title: data obj.title
'
)
const
provideDataObjContentEl
=
await
page
.
$
(
'
.provide-data-obj-content
'
)
let
provideDataObjContentText
=
await
provideDataObjContentEl
.
text
()
expect
(
provideDataObjContentText
).
toBe
(
'
provideDataObj.content: data obj.content
'
)
const
changeDataBtn
=
await
page
.
$
(
'
.change-data-btn
'
)
await
changeDataBtn
.
tap
()
computedTitleText
=
await
computedTitleEl
.
text
()
expect
(
computedTitleText
).
toBe
(
'
computedTitle: 字面量方式定义 provide page title changed
'
)
provideDataObjTitleText
=
await
provideDataObjTitleEl
.
text
()
expect
(
provideDataObjTitleText
).
toBe
(
'
provideDataObj.title: new title
'
)
provideDataObjContentText
=
await
provideDataObjContentEl
.
text
()
expect
(
provideDataObjContentText
).
toBe
(
'
provideDataObj.content: new content
'
)
)
})
})
it
(
'
string
'
,
async
()
=>
{
it
(
'
string
'
,
async
()
=>
{
...
...
pages/composition/provide/provide.uvue
浏览文件 @
71b7504b
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
<button class="uni-common-mt" @click="goProvidePage2">
<button class="uni-common-mt" @click="goProvidePage2">
跳转函数方式定义 provide 示例
跳转函数方式定义 provide 示例
</button>
</button>
<button class="uni-common-mt change-data-btn" @click="changeData">change data</button>
<ComponentForInject />
<ComponentForInject />
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
...
@@ -33,9 +32,6 @@ export default {
...
@@ -33,9 +32,6 @@ export default {
}
}
},
},
provide: {
provide: {
providePageTitle: this.title,
computedTitle: computed<string>((): string => this.title),
provideDataObj: this.obj,
providePageStr: '字面量方式定义 provide page str',
providePageStr: '字面量方式定义 provide page str',
providePageNum: 1,
providePageNum: 1,
providePageBool: true,
providePageBool: true,
...
@@ -52,11 +48,6 @@ export default {
...
@@ -52,11 +48,6 @@ export default {
uni.navigateTo({
uni.navigateTo({
url: '/pages/composition/provide/provide-page2'
url: '/pages/composition/provide/provide-page2'
})
})
},
changeData() {
this.title = '字面量方式定义 provide page title changed'
this.obj['title'] = 'new title'
this.obj['content'] = 'new content'
}
}
},
},
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录