el-select 默认怎么是数字, 显示对应的label。js 字符串转数字

el-select 默认怎么是数字

< el-select v-model="day" >
< el-option v-for="item in options" :key="item.day" :label="item.label" :value="item.day" >
el-option >
el-select >



// 选择的时间

day: 1,


options: [{
day: 1,
label: '今天'
}, {
day: 7,
label: '近7天'
}, {
day: 30,
label: '近30天'
}],

el-select 默认怎么是数字, 显示对应的label

问题还是在于 其他地方 对day 赋值了, 赋值不是 数字类型 而是字符串类型。

就是这句

this.day = this.$route.params.day

js 字符串转数字

this.day = parseInt( this.$route.params.day)

你可能感兴趣的:(el-select 默认怎么是数字, 显示对应的label。js 字符串转数字)