美文网首页
uniapp picker选择器

uniapp picker选择器

作者: 吃肉肉不吃肉肉 | 来源:发表于2021-03-11 17:35 被阅读0次

效果:

image.png

源码:

<template>
    <view class="bground">
        <picker class="select" mode="selector" :range="title_list" range-key="name" @change="titlePicker">
            <view style="color: #FB231F">
                {{title}}
                <text></text>
                <image src="../../static/new_my/new_honor/triangle.png" mode="widthFix" style="width: 25rpx;margin-left: 20rpx;"></image>
            </view>
        </picker>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                honor:false,
                title: '活动的标题点击此处选择',
                title_list:[
                    {id:12,name:'测试1'},
                    {id:25,name:'测试2'}
                ]
            }
        },
        methods:{
            titlePicker(e){ 
               this.title = this.title_list[e.target.value].title
                console.log(this.title_list[e.target.value].id) //获取id
        },
    }
</script>

相关文章

网友评论

      本文标题:uniapp picker选择器

      本文链接:https://www.haomeiwen.com/subject/ujxoqltx.html