4 changed files with 89 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||||
|
// components/segment/index.js
|
||||
|
Component({ |
||||
|
/** |
||||
|
* 组件的属性列表 |
||||
|
*/ |
||||
|
properties: { |
||||
|
headerTitles: Array, |
||||
|
selectedTitle: Number |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 组件的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 组件的方法列表 |
||||
|
*/ |
||||
|
methods: { |
||||
|
bindtap: function (e) { |
||||
|
const { item } = e.currentTarget.dataset |
||||
|
this.triggerEvent('tapSegment', item) |
||||
|
}, |
||||
|
} |
||||
|
}) |
@ -0,0 +1,4 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": {} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
<!--components/segment/index.wxml--> |
||||
|
<view class="main"> |
||||
|
<scroll-view scroll-x scroll-into-view=''> |
||||
|
<view class="header-titles"> |
||||
|
<block wx:for="{{headerTitles}}" wx:key="index" > |
||||
|
<view class="item-title"> |
||||
|
<view id="{{index}}" bindtap="bindtap" data-item="{{index}}" class="title {{index==selectedTitle ? 'title-selected' : ''}}"> |
||||
|
{{item}} |
||||
|
</view> |
||||
|
<view class="select-line" hidden="{{index==selectedTitle ? false : true}}"></view> |
||||
|
</view> |
||||
|
</block> |
||||
|
</view> |
||||
|
</scroll-view> |
||||
|
</view> |
||||
|
|
@ -0,0 +1,42 @@ |
|||||
|
/* components/segment/index.wxss */ |
||||
|
.header-titles { |
||||
|
height: 36px; |
||||
|
display: flex; |
||||
|
/* justify-content: space-around; */ |
||||
|
padding: 5px; |
||||
|
} |
||||
|
.title { |
||||
|
width: 150rpx; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
color: #999999; |
||||
|
font-size: 14px; |
||||
|
margin-top: 5px; |
||||
|
} |
||||
|
.item-title{ |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.title-selected { |
||||
|
font-size: 16px; |
||||
|
color: #292E3E; |
||||
|
} |
||||
|
.select-line{ |
||||
|
margin-top: 4px; |
||||
|
width: 10px; |
||||
|
height: 2px; |
||||
|
border-radius: 5px; |
||||
|
background-color: #FA4646; |
||||
|
} |
||||
|
|
||||
|
.main{ |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
font-size: 90rpx; |
||||
|
color: white; |
||||
|
} |
Loading…
Reference in new issue