Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
34485147
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看板
提交
34485147
编写于
11月 14, 2024
作者:
F
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v-bind): 补充v-bind="obj"各种测试例
上级
54314d03
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
68 addition
and
12 deletion
+68
-12
pages/directive/v-bind/v-bind-composition.uvue
pages/directive/v-bind/v-bind-composition.uvue
+27
-5
pages/directive/v-bind/v-bind-options.uvue
pages/directive/v-bind/v-bind-options.uvue
+28
-5
pages/directive/v-bind/v-bind.test.js
pages/directive/v-bind/v-bind.test.js
+13
-2
未找到文件。
pages/directive/v-bind/v-bind-composition.uvue
浏览文件 @
34485147
<template>
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="page">
<view class="page">
<!-- v-bind attribute -->
<!-- v-bind attribute -->
<button id="disabled-btn" class="mb-10" :disabled="true">
<button id="disabled-btn" class="mb-10" :disabled="true">
...
@@ -25,13 +28,27 @@
...
@@ -25,13 +28,27 @@
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<!-- v-bind props -->
<Foo checked />
<Foo checked />
<!-- 绑定对象 -->
<Foo id="bindObj1" v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" />
<!-- 绑定对象合并-->
<Foo id="bindObj2" v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" title="foo title override" />
<!-- 绑定对象合并-->
<Foo id="bindObj3" title="foo" v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" />
<!-- 绑定对象合并(UTSJSONObject)-->
<Foo id="bindObj4" v-bind="fooProps" title="foo title(json) override" />
<!-- 绑定对象合并(UTSJSONObject)-->
<Foo id="bindObj5" title="foo" v-bind="fooProps" />
<!-- v-bind in style -->
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
<!-- #endif -->
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
</template>
<script setup lang="uts">
<script setup lang="uts">
...
@@ -60,7 +77,12 @@
...
@@ -60,7 +77,12 @@
},
},
vBindClassBackgroundColor: 'red',
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
vBindClassRpxHeight: '300rpx'
} as DataInfo)
} as DataInfo)
const fooProps = reactive({
title: 'foo title(json)',
num: 2,
})
defineExpose({
defineExpose({
dataInfo
dataInfo
...
...
pages/directive/v-bind/v-bind-options.uvue
浏览文件 @
34485147
<template>
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="page">
<view class="page">
<!-- v-bind attribute -->
<!-- v-bind attribute -->
<button id="disabled-btn" class="mb-10" :disabled="true">:disabled true</button>
<button id="disabled-btn" class="mb-10" :disabled="true">:disabled true</button>
...
@@ -21,13 +24,29 @@
...
@@ -21,13 +24,29 @@
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<!-- v-bind props -->
<Foo checked />
<Foo checked />
<!-- 绑定对象 -->
<Foo v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" />
<Foo v-bind="fooProps"/>
<Foo id="bindObj1" v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" />
<!-- 绑定对象合并 v-bind 在前 -->
<Foo v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" id="bindObj2" :title="dataInfo.fooProps.title + ' override'" />
<!-- 绑定对象合并 v-bind 在后 -->
<Foo id="bindObj3" title="foo" v-bind="{ title: dataInfo.fooProps.title,num: dataInfo.fooProps.num,obj: dataInfo.fooProps.obj }" />
<!-- 绑定对象合并 v-bind 在中间(UTSJSONObject)-->
<Foo id="bindObj4" v-bind="fooProps" title="foo title(json) override" />
<!-- 绑定对象合并(UTSJSONObject)-->
<Foo id="bindObj5" title="foo" v-bind="fooProps" />
<!-- v-bind in style -->
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
<!-- #endif -->
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
</template>
<script lang="uts">
<script lang="uts">
...
@@ -60,7 +79,11 @@
...
@@ -60,7 +79,11 @@
},
},
vBindClassBackgroundColor: 'red',
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
vBindClassRpxHeight: '300rpx'
} as DataInfo
} as DataInfo,
fooProps:{
title: 'foo title(json)',
num: 2,
}
}
}
}
}
}
}
...
...
pages/directive/v-bind/v-bind.test.js
浏览文件 @
34485147
...
@@ -44,8 +44,19 @@ describe('v-bind', () => {
...
@@ -44,8 +44,19 @@ describe('v-bind', () => {
const
fooPropsNum
=
await
page
.
$
(
'
#foo-props-num
'
)
const
fooPropsNum
=
await
page
.
$
(
'
#foo-props-num
'
)
expect
(
await
fooPropsNum
.
text
()).
toBe
(
dataInfo
.
fooProps
.
num
.
toString
())
expect
(
await
fooPropsNum
.
text
()).
toBe
(
dataInfo
.
fooProps
.
num
.
toString
())
const
fooPropsObjName
=
await
page
.
$
(
'
#foo-props-obj-name
'
)
const
fooPropsObjName
=
await
page
.
$
(
'
#foo-props-obj-name
'
)
expect
(
await
fooPropsObjName
.
text
()).
toBe
(
dataInfo
.
fooProps
.
obj
.
name
)
expect
(
await
fooPropsObjName
.
text
()).
toBe
(
dataInfo
.
fooProps
.
obj
.
name
)
const
bindObj1
=
await
page
.
$
(
'
#bindObj1
'
)
expect
(
await
(
await
bindObj1
.
$
(
'
#foo-props-title
'
)).
text
()).
toBe
(
dataInfo
.
fooProps
.
title
)
const
bindObj2
=
await
page
.
$
(
'
#bindObj2
'
)
expect
(
await
(
await
bindObj2
.
$
(
'
#foo-props-title
'
)).
text
()).
toBe
(
dataInfo
.
fooProps
.
title
+
'
override
'
)
const
bindObj3
=
await
page
.
$
(
'
#bindObj3
'
)
expect
(
await
(
await
bindObj3
.
$
(
'
#foo-props-title
'
)).
text
()).
toBe
(
dataInfo
.
fooProps
.
title
)
const
bindObj4
=
await
page
.
$
(
'
#bindObj4
'
)
expect
(
await
(
await
bindObj4
.
$
(
'
#foo-props-title
'
)).
text
()).
toBe
(
`foo title(json) override`
)
const
bindObj5
=
await
page
.
$
(
'
#bindObj5
'
)
expect
(
await
(
await
bindObj5
.
$
(
'
#foo-props-title
'
)).
text
()).
toBe
(
`foo title(json)`
)
if
(
isWeb
)
{
if
(
isWeb
)
{
const
vBindCss
=
await
page
.
$
(
'
.v-bind-css
'
)
const
vBindCss
=
await
page
.
$
(
'
.v-bind-css
'
)
expect
(
await
vBindCss
.
style
(
'
backgroundColor
'
)).
toBe
(
'
rgb(255, 0, 0)
'
)
expect
(
await
vBindCss
.
style
(
'
backgroundColor
'
)).
toBe
(
'
rgb(255, 0, 0)
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录