准备联调抄表记录
This commit is contained in:
31
components/Segmented/index.js
Normal file
31
components/Segmented/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// components/Segmented/index.js
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
list: Array,
|
||||
active: Number,
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
handleChange(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
if (index === this.data.active) {
|
||||
return;
|
||||
}
|
||||
this.triggerEvent("change", { index, name: this.data.list[index] })
|
||||
}
|
||||
}
|
||||
})
|
||||
4
components/Segmented/index.json
Normal file
4
components/Segmented/index.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
12
components/Segmented/index.wxml
Normal file
12
components/Segmented/index.wxml
Normal file
@@ -0,0 +1,12 @@
|
||||
<!--components/Segmented/index.wxml-->
|
||||
<view style="margin: 10rpx 20rpx">
|
||||
<view
|
||||
wx:for="{{list}}"
|
||||
wx:key="index"
|
||||
class="item {{index === active ? 'active' : ''}}"
|
||||
bind:tap="handleChange"
|
||||
data-index="{{index}}"
|
||||
>
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
19
components/Segmented/index.wxss
Normal file
19
components/Segmented/index.wxss
Normal file
@@ -0,0 +1,19 @@
|
||||
/* components/Segmented/index.wxss */
|
||||
.item {
|
||||
display: inline-block;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #ccc;
|
||||
border-right: 0rpx;
|
||||
font-size: 32rpx;
|
||||
min-width: 140rpx;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
.item:nth-last-child(1) {
|
||||
border-right: 1rpx solid #ccc;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: var(--middle-green);
|
||||
}
|
||||
Reference in New Issue
Block a user