You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< template >
< view class = "container" >
< picker -view
@change ="onPickerChange"
mask -style = " opacity : 0 % "
indicator -style = " height : 3rem "
:value ="pickerValue"
class = "picker_view_box"
>
< picker -view -column >
< view v-for ="(item, index) in options" :key="index" class="item">
{{ item }}
</view>
</picker-view-column>
</picker-view>
<image class="button" @click="go_to_weight_end" src="/static/information/girl_weight/pictures/button_roll.png" > < / image >
< / view >
< / template >
< script >
export default {
data ( ) {
return {
options : this . generateWeightOptions ( 40 , 150 ) ,
pickerValue : [ 15 ] , // 默认选中项的索引
} ;
} ,
methods : {
generateWeightOptions ( start , end ) {
const options = [ ] ;
for ( let i = start ; i <= end ; i ++ ) {
options . push ( ` ${ i } kg ` ) ;
}
return options ;
} ,
onPickerChange ( event ) {
this . pickerValue = event . detail . value ; // 更新选中的索引
} ,
navigateTo ( page ) {
uni . navigateTo ( {
url : page
} ) ;
} ,
go _to _weight _end ( ) {
const selectedValue = this . options [ this . pickerValue [ 0 ] ] ; // 获取选中的值
this . navigateTo ( ` /pages/information/girl_weight_end/girl_weight_end?weight= ${ selectedValue } ` ) ; // 跳转到 boy_weight_end, 并传递选中值
} ,
} ,
} ;
< / script >
< style scoped >
. container {
display : flex ;
flex - direction : column ;
align - items : center ; /* 水平居中 */
justify - content : center ; /* 垂直居中 */
height : 100 vh ; /* 使容器充满整个视口 */
background - image : url ( "/static/information/girl_weight/pictures/bkg_roll.png" ) ;
background - size : cover ;
}
. picker _view _box {
height : 42.8 vh ; /* 设置 picker-view 的高度 */
width : 80 % ; /* 宽度自适应 */
}
. item {
line - height : 2 rem ;
display : flex ;
align - items : center ;
justify - content : center ;
font - size : 1.5 rem ;
height : 3 rem ;
color : # ffffff ;
}
. button {
margin - top : 10 px ; /* 按钮与选择器之间的间距 */
position : absolute ;
height : 13 % ;
width : 80 % ;
right : 10 % ; /* 距右边 10% */
bottom : 2 % ; /* 距底部 3.5% */
}
< / style >