<el-select
v-model="selectedValue"
placeholder="请选择"
class="typeSelect"
size="mini"
popper-class="select_dropdown_css"
@change="selectEvent"
>
<el-option
v-for="(item, index) in selectOptions"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
data () {
return {
selectedValue: '',
selectOptions: []
}
}
getSeventDay () {
// 设置日期,当前日期的前七天
var myDate = new Date() // 获取今天日期
myDate.setDate(myDate.getDate() - 6)
var dateArray = []
var dateTemp, dateTempYear
var flag = 1
// console.log(myDate.getFullYear(),myDate.getMonth(),myDate.getDate())
for (var i = 0; i < 7; i++) {
// label,月日
dateTemp = (myDate.getMonth() + 1) + '-' + myDate.getDate()
// value,年月日
dateTempYear = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate()
dateArray.push({ label: dateTemp, value: dateTempYear })
myDate.setDate(myDate.getDate() + flag)
}
// console.log(dateArray)
this.selectOptions = dateArray.reverse()
this.selectedValue = this.selectOptions[0].value
},