this.table.search.dateRange[0]获取开始日期,通过访问this.table.search.dateRange[1]获取结束日期。需要变为start_time和end_time
时间: 2024-04-11 15:33:22 浏览: 6
如果你想将`this.table.search.dateRange[0]`作为开始日期,`this.table.search.dateRange[1]`作为结束日期存储到`start_time`和`end_time`变量中,你可以在Vue组件中进行如下修改:
1. 在Vue组件的`data`属性中定义`start_time`和`end_time`变量:
```javascript
data() {
return {
start_time: '',
end_time: '',
table: {
search: {
dateRange: [] // 存储日期范围的数组
}
}
};
},
```
2. 在el-date-picker组件的`v-model`属性中绑定`table.search.dateRange`数组:
```html
<el-form-item prop="date_de">
<el-date-picker
v-model="table.search.dateRange"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
</el-form-item>
```
3. 在Vue组件的`watch`属性中监听`table.search.dateRange`的变化,并将开始日期和结束日期分别存储到`start_time`和`end_time`变量中:
```javascript
watch: {
'table.search.dateRange'(newVal) {
this.start_time = newVal[0];
this.end_time = newVal[1];
}
},
```
现在,当用户选择日期范围时,`start_time`变量将会更新为选择的开始日期,而`end_time`变量将会更新为选择的结束日期。
希望这次回答能够满足你的需求,如果还有其他问题,请随时提问。