Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
03b81882
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6006
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
03b81882
编写于
5月 31, 2024
作者:
辛宝Otto
🥊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 补充 checkbox iconColor/foreColor 相关测试
上级
6f43d7ec
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
203 addition
and
203 deletion
+203
-203
pages/component/checkbox/checkbox.uvue
pages/component/checkbox/checkbox.uvue
+203
-203
未找到文件。
pages/component/checkbox/checkbox.uvue
浏览文件 @
03b81882
<script>
<script>
type ItemType = {
type ItemType = {
value : string
value : string
name : string
name : string
checked : boolean
checked : boolean
}
}
export default {
export default {
data() {
data() {
return {
return {
items: [
items: [
{
{
value: 'CHN',
value: 'CHN',
name: '中国',
name: '中国',
checked: true,
checked: true,
},
},
{
{
value: 'USA',
value: 'USA',
name: '美国',
name: '美国',
checked: false,
checked: false,
},
},
{
{
value: 'BRA',
value: 'BRA',
name: '巴西',
name: '巴西',
checked: false,
checked: false,
},
},
{
{
value: 'JPN',
value: 'JPN',
name: '日本',
name: '日本',
checked: false,
checked: false,
},
},
{
{
value: 'ENG',
value: 'ENG',
name: '英国',
name: '英国',
checked: false,
checked: false,
},
},
{
{
value: 'FRA',
value: 'FRA',
name: '法国',
name: '法国',
checked: false,
checked: false,
},
},
] as ItemType[],
] as ItemType[],
testEvent: false,
testEvent: false,
text: '未选中',
text: '未选中',
wrapText: 'uni-app x,终极跨平台方案\nuts,大一统语言',
wrapText: 'uni-app x,终极跨平台方案\nuts,大一统语言',
value: [] as string[],
value: [] as string[],
disabled: true,
disabled: true,
checked: true,
checked: true,
color: '#007aff',
color: '#007aff',
iconColor: '#211cfe',
iconColor: '#211cfe',
foreColor: '#ff0000',
foreColor: '#ff0000',
// 组件属性 autotest
// 组件属性 autotest
checked_boolean: false,
checked_boolean: false,
disabled_boolean: false,
disabled_boolean: false,
color_input: "#007aff",
color_input: "#007aff",
backgroundColor_input: "#ffffff",
backgroundColor_input: "#ffffff",
borderColor_input: "#d1d1d1",
borderColor_input: "#d1d1d1",
activeBackgroundColor_input: "#ffffff",
activeBackgroundColor_input: "#ffffff",
activeBorderColor_input: "#d1d1d1",
activeBorderColor_input: "#d1d1d1",
iconColor_input: "#007aff",
iconColor_input: "#007aff",
foreColor_input: '#ff0000'
foreColor_input: '#ff0000'
}
}
},
},
methods: {
methods: {
checkboxChange: function (e : UniCheckboxGroupChangeEvent) {
checkboxChange: function (e : UniCheckboxGroupChangeEvent) {
// 自动化测试
// 自动化测试
if ((e.target?.tagName ?? '') == 'CHECKBOX-GROUP' && e.type === 'change') {
if ((e.target?.tagName ?? '') == 'CHECKBOX-GROUP' && e.type === 'change') {
this.testEvent = true
this.testEvent = true
}
}
const selectedNames : string[] = []
const selectedNames : string[] = []
this.items.forEach((item) => {
this.items.forEach((item) => {
if (e.detail.value.includes(item.value)) {
if (e.detail.value.includes(item.value)) {
selectedNames.push(item.name)
selectedNames.push(item.name)
}
}
})
})
uni.showToast({
uni.showToast({
icon: 'none',
icon: 'none',
title: '当前选中:' + selectedNames.join(','),
title: '当前选中:' + selectedNames.join(','),
})
})
},
},
testChange: function (e : UniCheckboxGroupChangeEvent) {
testChange: function (e : UniCheckboxGroupChangeEvent) {
this.value = e.detail.value
this.value = e.detail.value
},
},
checkbox_click() { console.log("组件被点击时触发") },
checkbox_click() { console.log("组件被点击时触发") },
checkbox_touchstart() { console.log("手指触摸动作开始") },
checkbox_touchstart() { console.log("手指触摸动作开始") },
checkbox_touchmove() { console.log("手指触摸后移动") },
checkbox_touchmove() { console.log("手指触摸后移动") },
checkbox_touchcancel() { console.log("手指触摸动作被打断,如来电提醒,弹窗") },
checkbox_touchcancel() { console.log("手指触摸动作被打断,如来电提醒,弹窗") },
checkbox_touchend() { console.log("手指触摸动作结束") },
checkbox_touchend() { console.log("手指触摸动作结束") },
checkbox_tap() { console.log("手指触摸后马上离开") },
checkbox_tap() { console.log("手指触摸后马上离开") },
checkbox_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
checkbox_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
change_checked_boolean(checked : boolean) { this.checked_boolean = checked },
change_checked_boolean(checked : boolean) { this.checked_boolean = checked },
change_disabled_boolean(checked : boolean) { this.disabled_boolean = checked },
change_disabled_boolean(checked : boolean) { this.disabled_boolean = checked },
confirm_color_input(value : string) { this.color_input = value },
confirm_color_input(value : string) { this.color_input = value },
confirm_backgroundColor_input(value : string) { this.backgroundColor_input = value },
confirm_backgroundColor_input(value : string) { this.backgroundColor_input = value },
confirm_borderColor_input(value : string) { this.borderColor_input = value },
confirm_borderColor_input(value : string) { this.borderColor_input = value },
confirm_activeBackgroundColor_input(value : string) { this.activeBackgroundColor_input = value },
confirm_activeBackgroundColor_input(value : string) { this.activeBackgroundColor_input = value },
confirm_activeBorderColor_input(value : string) { this.activeBorderColor_input = value },
confirm_activeBorderColor_input(value : string) { this.activeBorderColor_input = value },
confirm_iconColor_input(value : string) { this.iconColor_input = value },
confirm_iconColor_input(value : string) { this.iconColor_input = value },
confirm_foreColor_input(value : string) { this.foreColor_input = value }
confirm_foreColor_input(value : string) { this.foreColor_input = value }
}
}
}
}
</script>
</script>
<template>
<template>
<view class="main">
<view class="main">
<checkbox :disabled="disabled_boolean" :checked="checked_boolean" :color="color_input" :iconColor="iconColor_input"
<checkbox :disabled="disabled_boolean" :checked="checked_boolean" :color="color_input" :iconColor="iconColor_input"
:foreColor="foreColor_input" :backgroundColor="backgroundColor_input" :borderColor="borderColor_input"
:foreColor="foreColor_input" :backgroundColor="backgroundColor_input" :borderColor="borderColor_input"
:activeBackgroundColor="activeBackgroundColor_input" :activeBorderColor="activeBorderColor_input"
:activeBackgroundColor="activeBackgroundColor_input" :activeBorderColor="activeBorderColor_input"
@click="checkbox_click" @touchstart="checkbox_touchstart" @touchmove="checkbox_touchmove"
@click="checkbox_click" @touchstart="checkbox_touchstart" @touchmove="checkbox_touchmove"
@touchcancel="checkbox_touchcancel" @touchend="checkbox_touchend" @tap="checkbox_tap"
@touchcancel="checkbox_touchcancel" @touchend="checkbox_touchend" @tap="checkbox_tap"
@longpress="checkbox_longpress"><text>uni-app-x</text></checkbox>
@longpress="checkbox_longpress"><text>uni-app-x</text></checkbox>
</view>
</view>
<scroll-view style="flex: 1">
<scroll-view style="flex: 1">
<view class="content">
<view class="content">
<page-head title="组件属性"></page-head>
<page-head title="组件属性"></page-head>
<boolean-data :defaultValue="false" title="当前是否选中,可用来设置默认选中" @change="change_checked_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="当前是否选中,可用来设置默认选中" @change="change_checked_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="是否禁用" @change="change_disabled_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="是否禁用" @change="change_disabled_boolean"></boolean-data>
<input-data defaultValue="#007aff" title="checkbox的颜色" type="text" @confirm="confirm_color_input"></input-data>
<input-data defaultValue="#007aff" title="checkbox的颜色" type="text" @confirm="confirm_color_input"></input-data>
<input-data defaultValue="#ffffff" title="checkbox默认的背景颜色" type="text"
<input-data defaultValue="#ffffff" title="checkbox默认的背景颜色" type="text"
@confirm="confirm_backgroundColor_input"></input-data>
@confirm="confirm_backgroundColor_input"></input-data>
<input-data defaultValue="#d1d1d1" title="checkbox默认的边框颜色" type="text"
<input-data defaultValue="#d1d1d1" title="checkbox默认的边框颜色" type="text"
@confirm="confirm_borderColor_input"></input-data>
@confirm="confirm_borderColor_input"></input-data>
<input-data defaultValue="#ffffff" title="checkbox选中时的背景颜色" type="text"
<input-data defaultValue="#ffffff" title="checkbox选中时的背景颜色" type="text"
@confirm="confirm_activeBackgroundColor_input"></input-data>
@confirm="confirm_activeBackgroundColor_input"></input-data>
<input-data defaultValue="#d1d1d1" title="checkbox选中时的边框颜色" type="text"
<input-data defaultValue="#d1d1d1" title="checkbox选中时的边框颜色" type="text"
@confirm="confirm_activeBorderColor_input"></input-data>
@confirm="confirm_activeBorderColor_input"></input-data>
<input-data defaultValue="#007aff" title="iconColor: checkbox的图标颜色,优先级大于color属性" type="text"
<input-data defaultValue="#007aff" title="iconColor: checkbox的图标颜色,优先级大于color属性" type="text"
@confirm="confirm_iconColor_input"></input-data>
@confirm="confirm_iconColor_input"></input-data>
<input-data defaultValue="#ff0000" title="foreColor: checkbox的图标颜色,优先级大于color属性" type="text"
<input-data defaultValue="#ff0000" title="foreColor: checkbox的图标颜色,优先级大于color属性" type="text"
@confirm="confirm_foreColor_input"></input-data>
@confirm="confirm_foreColor_input"></input-data>
</view>
</view>
<view>
<view>
<page-head title="默认及使用"></page-head>
<page-head title="默认及使用"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title uni-common-mt">
<view class="uni-title uni-common-mt">
<text class="uni-title-text"> 默认样式 </text>
<text class="uni-title-text"> 默认样式 </text>
</view>
</view>
<view>
<view>
<checkbox-group class="uni-flex uni-row checkbox-group" @change="testChange" style="flex-wrap: wrap">
<checkbox-group class="uni-flex uni-row checkbox-group" @change="testChange" style="flex-wrap: wrap">
<checkbox value="cb" :checked="checked" :color="color" :iconColor="iconColor" :foreColor="foreColor"
<checkbox value="cb" :checked="checked" :color="color" :iconColor="iconColor" :foreColor="foreColor"
style="margin-right: 15px" class="checkbox cb">选中
style="margin-right: 15px" class="checkbox cb">选中
</checkbox>
</checkbox>
<checkbox value="cb1" style="margin-right: 15px" class="checkbox cb1">{{ text }}</checkbox>
<checkbox value="cb1" style="margin-right: 15px" class="checkbox cb1">{{ text }}</checkbox>
<checkbox value="cb2" :disabled="disabled" class="checkbox cb2">禁用</checkbox>
<checkbox value="cb2" :disabled="disabled" class="checkbox cb2">禁用</checkbox>
<checkbox value="cb3" style="margin-top: 10px" class="checkbox cb3">
<checkbox value="cb3" style="margin-top: 10px" class="checkbox cb3">
{{ wrapText }}
{{ wrapText }}
</checkbox>
</checkbox>
</checkbox-group>
</checkbox-group>
</view>
</view>
<view class="uni-title uni-common-mt">
<view class="uni-title uni-common-mt">
<text class="uni-title-text"> 不同颜色和尺寸的checkbox </text>
<text class="uni-title-text"> 不同颜色和尺寸的checkbox </text>
</view>
</view>
<view>
<view>
<checkbox-group class="uni-flex uni-row checkbox-group">
<checkbox-group class="uni-flex uni-row checkbox-group">
<checkbox value="cb1" :checked="true" color="#FFCC33" style="transform: scale(0.7); margin-right: 15px"
<checkbox value="cb1" :checked="true" color="#FFCC33" style="transform: scale(0.7); margin-right: 15px"
class="checkbox">选中
class="checkbox">选中
</checkbox>
</checkbox>
<checkbox value="cb" color="#FFCC33" style="transform: scale(0.7)" class="checkbox">未选中</checkbox>
<checkbox value="cb" color="#FFCC33" style="transform: scale(0.7)" class="checkbox">未选中</checkbox>
</checkbox-group>
</checkbox-group>
</view>
</view>
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<view class="uni-title uni-common-mt">
<view class="uni-title uni-common-mt">
<text class="uni-title-text"> 推荐展示样式 </text>
<text class="uni-title-text"> 推荐展示样式 </text>
</view>
</view>
</view>
</view>
<view class="uni-list uni-common-pl">
<view class="uni-list uni-common-pl">
<checkbox-group @change="checkboxChange" class="checkbox-group" id="trigger-change">
<checkbox-group @change="checkboxChange" class="checkbox-group" id="trigger-change">
<checkbox class="uni-list-cell uni-list-cell-pd checkbox" v-for="(item, index) in items" :key="item.value"
<checkbox class="uni-list-cell uni-list-cell-pd checkbox" v-for="(item, index) in items" :key="item.value"
:value="item.value" :checked="item.checked" :class="[
:value="item.value" :checked="item.checked" :class="[
index < items.length - 1 ? 'uni-list-cell-line' : '',
index < items.length - 1 ? 'uni-list-cell-line' : '',
'checkbox-item-' + index,
'checkbox-item-' + index,
]">
]">
{{ item.name }}
{{ item.name }}
</checkbox>
</checkbox>
</checkbox-group>
</checkbox-group>
</view>
</view>
</view>
</view>
</scroll-view>
</scroll-view>
</template>
</template>
<style>
<style>
.main {
.main {
max-height: 250px;
max-height: 250px;
padding: 5px 0;
padding: 5px 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
flex-direction: row;
flex-direction: row;
justify-content: center;
justify-content: center;
}
}
.main .list-item {
.main .list-item {
width: 100%;
width: 100%;
height: 100px;
height: 100px;
border: 1px solid #666;
border: 1px solid #666;
}
}
.uni-list-cell {
.uni-list-cell {
justify-content: flex-start;
justify-content: flex-start;
}
}
</style>
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录