Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
d048b586
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看板
提交
d048b586
编写于
2月 02, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 增加 style 绑定 map 数据类型示例
上级
ca5dae6b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
243 addition
and
50 deletion
+243
-50
pages.json
pages.json
+11
-5
pages/rendering/template/template-map-style.test.js
pages/rendering/template/template-map-style.test.js
+18
-0
pages/rendering/template/template-map-style.uvue
pages/rendering/template/template-map-style.uvue
+165
-0
pages/rendering/template/template.uvue
pages/rendering/template/template.uvue
+49
-45
未找到文件。
pages.json
浏览文件 @
d048b586
...
@@ -317,6 +317,12 @@
...
@@ -317,6 +317,12 @@
"navigationBarTitleText"
:
"template"
"navigationBarTitleText"
:
"template"
}
}
},
},
{
"path"
:
"pages/rendering/template/template-map-style"
,
"style"
:
{
"navigationBarTitleText"
:
"template-map-style"
}
},
{
{
"path"
:
"pages/rendering/unrecognized-component/unrecognized-component"
,
"path"
:
"pages/rendering/unrecognized-component/unrecognized-component"
,
"style"
:
{
"style"
:
{
...
...
pages/rendering/template/template-map-style.test.js
0 → 100644
浏览文件 @
d048b586
describe
(
'
/pages/rendering/template/template-map-style
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/rendering/template/template-map-style
'
)
await
page
.
waitFor
(
1000
)
})
it
(
'
init screen shot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
})
it
(
'
change isClassValid screen shot
'
,
async
()
=>
{
const
btn
=
await
page
.
$
(
'
#btn
'
)
await
btn
.
tap
()
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
})
});
\ No newline at end of file
pages/rendering/template/template-map-style.uvue
0 → 100644
浏览文件 @
d048b586
<template>
<view class="page">
<view :style="[styleW200, styleRounded, styleBorder]" :class="[classPadding10, classBgRed]">
<text>width:200px;</text>
<text>padding:10px;</text>
<text>border-radius:8px;</text>
<text>border:1px solid #ccc;</text>
<text>background-color: red;</text>
<text class="text-white">this text color: #fff;</text>
</view>
<view :style="[stylePadding10, styleBgGreen, styleMargin10]"
:class="[classH200, classRounded, classBorder, classBorderRed]">
<text>height:200px;</text>
<text>margin:10px;</text>
<text>padding:10px;</text>
<text>border-radius:8px;</text>
<text>border:1px solid #ccc;</text>
<text>border-color:red;</text>
<text>background-color: green;</text>
<text class="text-blue">this text color: blue;</text>
</view>
<view :style="styleBgBlue" :class="classPadding10">
<text>padding:10px;</text>
<text>background-color: blue;</text>
<text class="text-red">this text color: red;</text>
</view>
<button class="uni-common-mt" id="btn" @click="toggleIsClassValid">toggle isClassValid</button>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
styleW200: new Map<string, string>([['width', '200px']]),
styleH200: new Map<string, string>([['height', '200px']]),
stylePadding10: new Map<string, string>([['padding', '10px']]),
styleMargin10: new Map<string, string>([['margin', '10px']]),
styleRounded: new Map<string, string>([['border-radius', '8px']]),
styleBorder: new Map<string, string>([['border', '1px solid #ccc']]),
styleBorderRed: new Map<string, string>([['border-color', 'red']]),
styleBorderBlue: new Map<string, string>([['border-color', 'blue']]),
styleBorderGreen: new Map<string, string>([['border-color', 'green']]),
styleBgGreen: new Map<string, string>([['background-color', 'green']]),
styleBgBlue: new Map<string, string>([['background-color', 'blue']]),
styleBgRed: new Map<string, string>([['background-color', 'red']]),
styleTextWhite: new Map<string, string>([['color', '#fff']]),
styleTextBlack: new Map<string, string>([['color', '#000']]),
styleTextRed: new Map<string, string>([['color', 'red']]),
styleTextBlue: new Map<string, string>([['color', 'blue']]),
styleTextGreen: new Map<string, string>([['color', 'green']]),
isClassValid: true,
classW200: new Map<string, boolean>([['w-200', true]]),
classH200: new Map<string, boolean>([['h-200', true]]),
classPadding10: new Map<string, boolean>([['padding-10', true]]),
classMargin10: new Map<string, boolean>([['margin-10', true]]),
classRounded: new Map<string, boolean>([['rounded', true]]),
classBorder: new Map<string, boolean>([['border', true]]),
classBorderRed: new Map<string, boolean>([['border-red', true]]),
classBorderBlue: new Map<string, boolean>([['border-blue', true]]),
classBorderGreen: new Map<string, boolean>([['border-green', true]]),
classBgGreen: new Map<string, boolean>([['bg-green', true]]),
classBgBlue: new Map<string, boolean>([['bg-blue', true]]),
classBgRed: new Map<string, boolean>([['bg-red', true]]),
classTextWhite: new Map<string, boolean>([['text-white', true]]),
classTextBlack: new Map<string, boolean>([['text-black', true]]),
classTextRed: new Map<string, boolean>([['text-red', true]]),
classTextBlue: new Map<string, boolean>([['text-blue', true]]),
classTextGreen: new Map<string, boolean>([['text-green', true]]),
}
},
methods: {
toggleIsClassValid(){
this.isClassValid = !this.isClassValid
this.classW200 = new Map<string, boolean>([['w-200', this.isClassValid]])
this.classH200 = new Map<string, boolean>([['h-200', this.isClassValid]])
this.classPadding10 = new Map<string, boolean>([['padding-10', this.isClassValid]])
this.classMargin10 = new Map<string, boolean>([['margin-10', this.isClassValid]])
this.classRounded = new Map<string, boolean>([['rounded', this.isClassValid]])
this.classBorder = new Map<string, boolean>([['border', this.isClassValid]])
this.classBorderRed = new Map<string, boolean>([['border-red', this.isClassValid]])
this.classBorderBlue = new Map<string, boolean>([['border-blue', this.isClassValid]])
this.classBorderGreen = new Map<string, boolean>([['border-green', this.isClassValid]])
this.classBgGreen = new Map<string, boolean>([['bg-green', this.isClassValid]])
this.classBgBlue = new Map<string, boolean>([['bg-blue', this.isClassValid]])
this.classBgRed = new Map<string, boolean>([['bg-red', this.isClassValid]])
this.classTextWhite = new Map<string, boolean>([['text-white', this.isClassValid]])
this.classTextBlack = new Map<string, boolean>([['text-black', this.isClassValid]])
this.classTextRed = new Map<string, boolean>([['text-red', this.isClassValid]])
this.classTextBlue = new Map<string, boolean>([['text-blue', this.isClassValid]])
this.classTextGreen = new Map<string, boolean>([['text-green', this.isClassValid]])
}
}
}
</script>
<style>
.w-200 {
width: 200px;
}
.h-200 {
height: 200px;
}
.padding-10 {
padding: 10px;
}
.margin-10 {
margin: 10px;
}
.rounded {
border-radius: 8px;
}
.border {
border: 1px solid #ccc;
}
.border-red {
border-color: red;
}
.border-green {
border-color: green;
}
.border-blue {
border-color: blue;
}
.bg-green {
background-color: green;
}
.bg-red {
background-color: red;
}
.bg-blue {
background-color: blue;
}
.text-white {
color: #fff;
}
.text-black {
color: #000;
}
.text-green {
color: green;
}
.text-red {
color: red;
}
.text-blue {
color: blue;
}
</style>
\ No newline at end of file
pages/rendering/template/template.uvue
浏览文件 @
d048b586
<template>
<template>
<view class="container">
<view class="page">
<template v-if="isShow">
<template v-if="isShow">
<view class="title">{{title}}</view>
<view class="title">{{title}}</view>
</template>
</template>
...
@@ -7,12 +7,13 @@
...
@@ -7,12 +7,13 @@
<template v-for="(item,index) in list" :key="index">
<template v-for="(item,index) in list" :key="index">
<view class="item">{{index+1}}.{{item.name}}</view>
<view class="item">{{index+1}}.{{item.name}}</view>
</template>
</template>
<button @click="goMapStyle">跳转绑定 Map 类型 style 页面</button>
</view>
</view>
</template>
</template>
<script>
<script>
type objType = {
type objType = {
name: string
name : string
}
}
export default {
export default {
data() {
data() {
...
@@ -31,6 +32,9 @@
...
@@ -31,6 +32,9 @@
methods: {
methods: {
handleShow() {
handleShow() {
this.isShow = !this.isShow
this.isShow = !this.isShow
},
goMapStyle() {
uni.navigateTo({ url: '/pages/rendering/template/template-map-style' })
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录