Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
3aba6423
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看板
提交
3aba6423
编写于
8月 10, 2023
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
v-bind: add attribute|class|style|props
上级
80fe6cda
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
265 addition
and
14 deletion
+265
-14
pages.json
pages.json
+24
-0
pages/directive/v-bind/counter.uvue
pages/directive/v-bind/counter.uvue
+21
-0
pages/directive/v-bind/v-bind-attribute.test.js
pages/directive/v-bind/v-bind-attribute.test.js
+14
-0
pages/directive/v-bind/v-bind-attribute.uvue
pages/directive/v-bind/v-bind-attribute.uvue
+20
-0
pages/directive/v-bind/v-bind-class.test.js
pages/directive/v-bind/v-bind-class.test.js
+17
-0
pages/directive/v-bind/v-bind-class.uvue
pages/directive/v-bind/v-bind-class.uvue
+47
-0
pages/directive/v-bind/v-bind-props.test.js
pages/directive/v-bind/v-bind-props.test.js
+16
-0
pages/directive/v-bind/v-bind-props.uvue
pages/directive/v-bind/v-bind-props.uvue
+31
-0
pages/directive/v-bind/v-bind-style.test.js
pages/directive/v-bind/v-bind-style.test.js
+18
-0
pages/directive/v-bind/v-bind-style.uvue
pages/directive/v-bind/v-bind-style.uvue
+23
-0
pages/directive/v-show/v-show.test.js
pages/directive/v-show/v-show.test.js
+14
-14
pages/index.uvue
pages/index.uvue
+20
-0
未找到文件。
pages.json
浏览文件 @
3aba6423
...
@@ -11,6 +11,30 @@
...
@@ -11,6 +11,30 @@
"navigationBarTitleText"
:
"v-bind"
"navigationBarTitleText"
:
"v-bind"
}
}
},
},
{
"path"
:
"pages/directive/v-bind/v-bind-class"
,
"style"
:
{
"navigationBarTitleText"
:
"v-bind-class"
}
},
{
"path"
:
"pages/directive/v-bind/v-bind-style"
,
"style"
:
{
"navigationBarTitleText"
:
"v-bind-style"
}
},
{
"path"
:
"pages/directive/v-bind/v-bind-props"
,
"style"
:
{
"navigationBarTitleText"
:
"v-bind-props"
}
},
//
{
//
"path"
:
"pages/directive/v-bind/v-bind-attribute"
,
//
"style"
:
{
//
"navigationBarTitleText"
:
"v-bind-attribute"
//
}
//
},
{
{
"path"
:
"pages/directive/v-for/v-for"
,
"path"
:
"pages/directive/v-for/v-for"
,
"style"
:
{
"style"
:
{
...
...
pages/directive/v-bind/counter.uvue
0 → 100644
浏览文件 @
3aba6423
<template>
<view>
<text class="count-id">{{id}}</text>
<text class="count-title">{{title}}</text>
</view>
</template>
<script>
export default {
props: {
id: {
type: Number,
default: 0
},
title: {
type: String,
default: ''
}
}
}
</script>
\ No newline at end of file
pages/directive/v-bind/v-bind-attribute.test.js
0 → 100644
浏览文件 @
3aba6423
const
PAGE_PATH
=
'
/pages/directive/v-bind/v-bind-attribute
'
describe
(
'
v-bind-attribute
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
attribute
'
,
async
()
=>
{
const
view1
=
await
page
.
$
(
'
.attribute
'
)
expect
(
await
view1
.
attribute
(
'
id1
'
)).
toBe
(
'
id1
'
)
expect
(
await
view1
.
attribute
(
'
id2
'
)).
toBe
(
'
id2
'
)
})
})
\ No newline at end of file
pages/directive/v-bind/v-bind-attribute.uvue
0 → 100644
浏览文件 @
3aba6423
<template>
<view class="page">
<view class="split-title">v-bind-attribute</view>
<!-- 绑定对象形式的 attribute -->
<view class="attribute" v-bind="{ 'id1': id1, 'id2': id2 }">
<text>绑定自定义属性</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
id1: 'id1',
id2: 'id2'
}
}
}
</script>
pages/directive/v-bind/v-bind-class.test.js
0 → 100644
浏览文件 @
3aba6423
const
PAGE_PATH
=
'
/pages/directive/v-bind/v-bind-class
'
describe
(
'
v-bind-class
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
rect
'
,
async
()
=>
{
const
rect1
=
await
page
.
$
(
'
.rect1
'
)
const
rect2
=
await
page
.
$
(
'
.rect2
'
)
const
rect3
=
await
page
.
$
(
'
.rect3
'
)
expect
(
await
rect1
.
attribute
(
'
class
'
)).
toBe
(
'
rect rect1 red
'
)
expect
(
await
rect2
.
attribute
(
'
class
'
)).
toBe
(
'
rect rect2 class-a class-b
'
)
expect
(
await
rect3
.
attribute
(
'
class
'
)).
toBe
(
'
rect rect3 class-a class-b class-c
'
)
})
})
\ No newline at end of file
pages/directive/v-bind/v-bind-class.uvue
0 → 100644
浏览文件 @
3aba6423
<template>
<view class="page">
<view class="split-title">v-bind-class</view>
<view class="rect rect1" :class="{ red: isRed }">背景红色</view>
<view class="rect rect2" :class="[classA, classB]">背景绿色(#008000), 边框2px蓝色(#0000FF)</view>
<view class="rect rect3" :class="[classA, { [classB]: isB, [classC]: isC }]">背景绿色(#008000), 边框8px蓝色(#0000FF)</view>
</view>
</template>
<script>
export default {
data() {
return {
isRed: true,
isB: true,
isC: true,
classA: 'class-a',
classB: 'class-b',
classC: 'class-c'
}
}
}
</script>
<style>
.rect {
width: 200px;
height: 100px;
margin: 5px 0;
}
.red {
background-color: #FF0000;
}
.class-a {
background-color: #008000;
}
.class-b {
border: 2px solid #0000FF;
}
.class-c {
border-width: 4px;
}
</style>
pages/directive/v-bind/v-bind-props.test.js
0 → 100644
浏览文件 @
3aba6423
const
PAGE_PATH
=
'
/pages/directive/v-bind/v-bind-props
'
describe
(
'
v-bind-props
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
counter1
'
,
async
()
=>
{
const
counter
=
await
page
.
$
(
'
.counter1
'
)
const
counterID
=
await
counter
.
$
(
'
.count-id
'
)
const
counterTitle
=
await
counter
.
$
(
'
.count-title
'
)
expect
(
await
counterID
.
text
()).
toBe
(
'
1
'
)
expect
(
await
counterTitle
.
text
()).
toBe
(
'
title
'
)
})
})
\ No newline at end of file
pages/directive/v-bind/v-bind-props.uvue
0 → 100644
浏览文件 @
3aba6423
<template>
<view class="page">
<view class="split-title">v-bind-props</view>
<counter class="counter1" :id="post.id" :title="post.title"></counter>
<!-- TODO 暂不支持 -->
<!-- <counter class="counter2" v-bind="post"></counter> -->
</view>
</template>
<script>
import counter from "./counter.uvue"
type CounterData = {
id : number,
title : string
}
export default {
components: {
counter
},
data() {
return {
post: {
id: 1,
title: 'title'
} as CounterData
}
}
}
</script>
\ No newline at end of file
pages/directive/v-bind/v-bind-style.test.js
0 → 100644
浏览文件 @
3aba6423
const
PAGE_PATH
=
'
/pages/directive/v-bind/v-bind-style
'
describe
(
'
v-bind-style
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
basic
'
,
async
()
=>
{
const
text
=
await
page
.
$
(
'
.text-font-size
'
)
const
view
=
await
page
.
$
(
'
.view-style
'
)
expect
(
await
text
.
style
(
'
fontSize
'
)).
toBe
(
'
14px
'
)
expect
(
await
view
.
style
(
'
backgroundColor
'
)).
toBe
(
'
#008000
'
)
expect
(
await
view
.
style
(
'
borderWidth
'
)).
toBe
(
'
2px
'
)
expect
(
await
view
.
style
(
'
borderColor
'
)).
toBe
(
'
#0000FF
'
)
})
})
\ No newline at end of file
pages/directive/v-bind/v-bind-style.uvue
0 → 100644
浏览文件 @
3aba6423
<template>
<view class="page">
<view class="split-title">v-bind-style</view>
<view>
<text class="text-font-size" :style="{fontSize: size + 'px'}">14px</text>
</view>
<view class="view-style" :style="[styleObjectA, styleObjectB]">
背景绿色(#008000), 边框2px蓝色(#0000FF)
</view>
</view>
</template>
<script>
export default {
data() {
return {
size: 14,
styleObjectA: 'background-color: #008000;',
styleObjectB: 'border: 2px solid #0000FF;'
}
}
}
</script>
pages/directive/v-show/v-show.test.js
浏览文件 @
3aba6423
...
@@ -16,21 +16,21 @@ describe('v-show', () => {
...
@@ -16,21 +16,21 @@ describe('v-show', () => {
await
toggle
.
tap
()
await
toggle
.
tap
()
expect
(
await
element
.
style
(
'
display
'
)).
toBe
(
'
flex
'
)
expect
(
await
element
.
style
(
'
display
'
)).
toBe
(
'
flex
'
)
})
})
it
(
'
screenshot
'
,
async
()
=>
{
//
it('screenshot', async () => {
const
toggle
=
await
page
.
$
(
'
.btn-toggle
'
)
//
const toggle = await page.$('.btn-toggle')
const
element
=
await
page
.
$
(
'
.hello
'
)
//
const element = await page.$('.hello')
const
image1
=
await
program
.
screenshot
()
//
const image1 = await program.screenshot()
expect
(
image1
).
toMatchSnapshot
()
//
expect(image1).toMatchSnapshot()
await
toggle
.
tap
()
//
await toggle.tap()
await
page
.
waitFor
(
20
)
//
await page.waitFor(20)
const
image2
=
await
program
.
screenshot
()
//
const image2 = await program.screenshot()
expect
(
image2
).
toMatchSnapshot
()
//
expect(image2).toMatchSnapshot()
await
toggle
.
tap
()
//
await toggle.tap()
await
page
.
waitFor
(
20
)
//
await page.waitFor(20)
const
image3
=
await
program
.
screenshot
()
//
const image3 = await program.screenshot()
expect
(
image3
).
toMatchSnapshot
()
//
expect(image3).toMatchSnapshot()
})
//
})
})
})
\ No newline at end of file
pages/index.uvue
浏览文件 @
3aba6423
...
@@ -113,6 +113,26 @@ export default {
...
@@ -113,6 +113,26 @@ export default {
url: 'v-bind',
url: 'v-bind',
enable: true,
enable: true,
},
},
{
name: 'v-bind-class',
url: 'v-bind/v-bind-class',
enable: true,
},
{
name: 'v-bind-style',
url: 'v-bind/v-bind-style',
enable: true,
},
{
name: 'v-bind-props',
url: 'v-bind/v-bind-props',
enable: true,
},
{
name: 'v-bind-attribute',
url: 'v-bind/v-bind-attribute',
enable: false,
},
{
{
name: 'v-model',
name: 'v-model',
url: 'v-model',
url: 'v-model',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录