uniapp小程序多行文本层级过高可以监听显示隐藏解决

本文介绍了如何在Vue页面中使用U-form和U-select组件实现动态省市区选择和时间日期输入,包括`showAddress`和`showTime`状态管理及对应的确认回调函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 代码

<template>
    <view class="page">
        
            <view class="selfCard">
        
                    <u-form-item label="省市区" required>
                        <u-input @click="showAddress=true" :disabled='true' v-model="postForm.customerModel.region"
                            placeholder="请选择省市区"></u-input>
                        <u-icon @click="showAddress=true" slot='right' name="arrow-down" color="#e0e0e0" size="28" />
                        <u-select v-model="showAddress" mode="mutil-column-auto" :list="listAddress"
                            @confirm="confirmAddress"></u-select>
                    </u-form-item>

                    <u-form-item label="时间日期" required>
                        <u-input v-model="postForm.customerModel.add_time" :disabled='true' placeholder="请输入时间日期"
                            @click='showTime=true'>
                        </u-input>
                        <u-icon @click="showAddress=true" slot='right' name="arrow-down" color="#e0e0e0" size="28" />
                        <u-picker mode="time" v-model="showTime" :params="params" @cancel="showTime=false"
                            @confirm="timeConfirm"></u-picker>
                    </u-form-item>
                

                    <view class="" style="z-index: -1;">
                        <view class="" style="margin: 20rpx 0;">
                            备注
                        </view>
                        <textarea v-show="isInputContentFocus" type="text" placeholder-style='color:#c0c4cc' value=""
                            v-model="postForm.customerModel.remarks" placeholder="请输入备注" />
                    </view>

                </u-form>
            </view>

    

    </view>
</template>
<script>
    export default {
        data() {
            return {
    
                // 时间
                showTime: false,
                params: {
                    year: true,
                    month: true,
                    day: true,
                    hour: true,
                    minute: true,
                    second: true
                },
                // 获取省市区
                showAddress: false,
                listAddress: [],
                // 多行文本输入框
                isInputContentFocus: true,
            }
        },
        computed: {
            shows() {
                const {
                    showTime,
                
                    showAddress
                } = this
                return {
                    showTime,
                
                    showAddress
                }
            },
        },
        watch: {
            shows(e) {
                if (e.showTime == true || e.showAddress == true) {
                    this.isInputContentFocus = false;
                } else {
                    this.isInputContentFocus = true;
                }
            }
        },
        onLoad(e) {
            uni.setNavigationBarTitle({
                title: e.title
            });
            this.pageParams = e;
            if (e.id) {
                this.getPageData();
            }
            this.getAddress()
            this.DepartmentDropdown()
        },
        methods: {
        
            // 省市区
            confirmAddress(e) {
                this.postForm.customerModel.region = e[0].label + '--' + e[1].label + '--' + e[2].label
                this.postForm.customerModel.province_id = e[0].value
                this.postForm.customerModel.city_id = e[1].value
                this.postForm.customerModel.area_id = e[2].value
                // this.showMarket = false
            },
            // 时间
            timeConfirm(e) {
                console.log('时间', e)
                this.postForm.customerModel.add_time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e
                    .minute + ':' + e
                    .second
            },
        

        }
    }
</script>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值