element 日期选择,要求显示默认当前月份,在绑定数据里的字段
1,首先获取当前月分
getNowTime() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth();
let toMonth = year + '-' + ('00'+ (month + 1)).substr(-2) ;
this.param.period = toMonth;
},
在created()里先执行this.getNowTime()
2, <el-table-column prop="period" label="计划周期" width="140">
<template slot-scope="scope">
<template v-if="edit_index == scope.$index">
<el-date-picker
@click.native.stop=""
v-model="param.period"
type="month"
value-format="yyyy-MM"
:default-value="new Date()"
placeholder="选择月">
</el-date-picker>
</template>
<template v-else>
{{scope.row.period}}
</template>
</template>
</el-table-column>
3,一切都好了,但运行的时候发现没有执行,后来发现在变得时候我清空了数据,所以,需要在编辑的时候再重新执行一遍this.getNowTime()