赞
踩
给选择器加上唯一key(下面的想看就看)
需求是用一个下拉切换时间维度的选择,分别为年度、季度、月度,但是开发的时候发现,当切换的时候,视图可正常切换,但点击选择时却发现选择器跑到了左上角,代码和问题截图如下:
问题代码:
<el-form inline> <el-form-item label="统计维度"> <el-select size="small" style="width: 80px;" v-model="timeCategory"> <el-option :value="item.value" :label="item.label" v-for="item in timeCategoryOption"></el-option> </el-select> </el-form-item> <el-form-item v-if="timeCategory===0" label="年度选择"> <el-date-picker type="year" format="yyyy年" value-format="yyyy-01-01 00:00:00, yyyy-12-31 23:59:59" v-model="topChooseTime" style="width: 150px;" size="small"></el-date-picker> </el-form-item> <el-form-item v-if="timeCategory===1" label="季度选择"> <el-select v-model="topChooseTime"> <el-option :value="item.value" :label="item.label" v-for="item in quarterOption"></el-option> </el-select> </el-form-item> <el-form-item v-if="timeCategory===2" label="月度选择"> <el-date-picker type="monthrange" value-format="yyyy-MM-dd" v-model="topChooseTime" style="width: 180px;" size="small"></el-date-picker> </el-form-item> </el-form>
<el-form inline> <el-form-item label="统计维度"> <el-select size="small" style="width: 80px;" v-model="timeCategory"> <el-option :value="item.value" :label="item.label" v-for="item in timeCategoryOption"></el-option> </el-select> </el-form-item> <el-form-item v-if="timeCategory===0" label="年度选择"> <el-date-picker type="year" key="yearSelect" format="yyyy年" value-format="yyyy-01-01 00:00:00, yyyy-12-31 23:59:59" v-model="topChooseTime" style="width: 150px;" size="small"></el-date-picker> </el-form-item> <el-form-item v-if="timeCategory===1" label="季度选择"> <el-select v-model="topChooseTime" key="quarterSelect"> <el-option :value="item.value" :label="item.label" v-for="item in quarterOption"></el-option> </el-select> </el-form-item> <el-form-item v-if="timeCategory===2" label="月度选择"> <el-date-picker type="monthrange" key="monthrange" value-format="yyyy-MM-dd" v-model="topChooseTime" style="width: 180px;" size="small"></el-date-picker> </el-form-item> </el-form>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。