解决tab选择年月日

问题:

在这里插入图片描述

当点击2013时未选中以及展开栏没有收起来
解决:

在这里插入图片描述

添加到年月到input的方法不仅要在月份中调用,还要在年份中调用,这样就不会有上述问题了

贴此demo代码

html:
		<dl id="person">
            <!-- 宝宝生日 -->
            <dd>
                <s>宝宝生日</s>
                <div id="age" name="age" class="input" @click="openBadyBrithy">{{currValArr}}</div>
            </dd>
            <div id="stage">
                <dl>
                    <dt>选择宝宝生日</dt>
                    <dd>
                        <h4>年份</h4>
                        <ul id="yearset" @click="clickBadyBirthey">
                            <li data-year="2012">2012</li>
                            <li data-year="2013">2013</li>
                            <li data-year="2014">2014</li>
                            <li data-year="2015">2015</li>
                            <li data-year="2016">2016</li>
                            <li data-year="2017">2017</li>
                            <li data-year="2018">2018</li>
                            <li data-year="2019">2019</li>
                        </ul>
                        <h4>月份</h4>
                        <ul id="monthset" @click="clickBadyMonth">
                            <li data-month="01">01</li>
                            <li data-month="02">02</li>
                            <li data-month="03">03</li>
                            <li data-month="04">04</li>
                            <li data-month="05">05</li>
                            <li data-month="06">06</li>
                            <li data-month="07">07</li>
                            <li data-month="08">08</li>
                            <li data-month="09">09</li>
                            <li data-month="10">10</li>
                            <li data-month="11">11</li>
                            <li data-month="12">12</li>
                        </ul>
                    </dd>
                </dl>
            </div>
        </dl>

css:

/* 外部盒子*/

#person {
width: 98%;
height: auto;
margin: 0 auto;
}
#person dd {
position: relative;
margin-bottom:10px;
}
#person dd s {
position: absolute;
height: 30px;
line-height: 30px;
font-style: normal;
color: #999;
top: 13px;
left: 8px;
font-size: 18px;
border-right: 1px solid #999;
text-align: center;
display: block;
width: 85px;
text-decoration: none;
}
.input {
border: 1px solid #ddd;
color: #333;
font-size: 18px;
height: 40px;
line-height: 40px;
width: 100%;
/* padding: 5px; */
overflow: hidden;
text-indent: 100px;
text-align: left;
background: #fff;
-webkit-appearance: none;
border-radius: 20px;
margin-bottom: 0;
}

/* 宝宝生日 */

#stage {
width: 99%;
height: 300px;
border: 1px solid #eee;
background: #fff;
display: none;
border-bottom: 2px solid #e53d7b;
}
#stage dt {
height: 40px;
line-height: 40px;
color: #333;
padding-left: 5px;
text-align: left;
font-style: normal;
font-size: 18px;
}
#stage dd {
height: 540px;
padding: 5px 10px 10px;
}
#stage h4 {
line-height: 30px;
height: 30px;
display: inline-block;
margin:0 auto 60px auto;
}
#stage ul {
width: 85%;
clear: both;
height: 60px;
float: right;
}
#stage ul li {
width: 20%;
text-align: center;
height:25px;
line-height: 25px;
margin: 2% 2%;
float: left;
border-radius: 17px;
border: 1px solid #999;
/* font-size: 32px; */
}
#stage ul li.c {
background: #e53d7b;
color: #fff;
}

js:

export default {
data () {
return {
year:’’,
month:’’,
// 宝宝年月
currValArr:’’,
}
},
components: {
BeeHeader,
BeeFooter
},
// 点击按钮显示对应的图片
methods: {
// -------------------------------
// 宝宝年份
clickBadyBirthey (e) {
let dom = e.target
var index = $(dom).index();
$("#yearset").find(“li”).eq(index).addClass(‘c’).siblings(‘li’).removeClass(‘c’);
this.year = dom.getAttribute(‘data-year’);
},
// 宝宝月份
clickBadyMonth (e) {
let dom = e.target
var index = $(dom).index();
$("#monthset").find(“li”).eq(index).addClass(‘c’).siblings(‘li’).removeClass(‘c’);
this.month = dom.getAttribute(‘data-month’);
// 在选择了月就隐藏宝宝生日列表
this.yearMonth();
// $("#stage").hide();
},
// 添加年月到input中
yearMonth () {
if(this.year!=’’&&this.month!=’’) {
this.currValArr = this.year+’/’+this.month;
$("#stage").hide();
// console.log(this.currValArr);
}
},
// 显示宝宝生日列表
openBadyBrithy () {
$("#stage").toggle();
},
// ---------------------------------

}

==========================0-0完结#o#------------------------------

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UniApp是一个基于Vue.js的跨平台UI框架,用于快速开发原生应用。Tab切换卡顿可能是由于性能优化不足、组件渲染效率低或数据同步延迟等原因导致的。以下是一些解决 UniApp Tab 切换卡顿的常见方法: 1. **优化界面渲染**: - 减少组件层级和复杂度,避免过度嵌套和不必要的计算。 - 使用`<keep-alive>`标签来缓存Tab页面,避免不必要的重新渲染。 - 使用懒加载策略,只在需要时动态加载内容。 2. **数据绑定优化**: - 避免在组件切换时进行大量的数据绑定和处理,确保数据更新最小化。 - 使用`v-model.lazy`或`$nextTick()`确保数据更新完成后再操作DOM。 3. **代码分割**: - 对大型Tab页进行代码分割,将大模块拆分为多个小模块,提高加载速度。 4. **网络请求优化**: - 使用异步加载和网络预加载,减少页面切换时的网络请求。 - 避免在`created`生命周期钩子中发起长时间的网络请求。 5. **使用性能检测工具**: - 使用UniApp的官方性能分析工具(如`uni-performance`)检查并定位瓶颈。 6. **代码重构和模块化**: - 优化业务逻辑,合理划分组件职责,提高代码复用和可维护性。 7. **硬件适配**: - 对不同设备的性能进行适配,比如减少动画效果或者调整图片资源。 8. **内存管理**: - 及时清除不需要的引用,避免内存泄漏。 如果你遇到具体问题,提供更详细的卡顿情况或代码片段,我可以给出更针对性的建议。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值