克隆和复制 vuex store state moment date
clone and copy vuex store state moment date
状态如下:
this.$store.state.fromDate
我想这样定义一个变量:
var newFrom = this.$store.state.fromDate.subtract(1, 'days');
没有修改this.$store.state.fromDate
的值
可能吗?
您可以clone时间日期:
// First, clone the moment date object
var newFrom = this.$store.state.fromDate.clone();
// Then, subtract
newFrom.subtract(1, 'days');
这不会减去 this.$store.state.fromDate
而是减去 newFrom
或者,在一行中:
var newFrom = this.$store.state.fromDate.clone().subtract(1, 'days');
状态如下:
this.$store.state.fromDate
我想这样定义一个变量:
var newFrom = this.$store.state.fromDate.subtract(1, 'days');
没有修改this.$store.state.fromDate
可能吗?
您可以clone时间日期:
// First, clone the moment date object
var newFrom = this.$store.state.fromDate.clone();
// Then, subtract
newFrom.subtract(1, 'days');
这不会减去 this.$store.state.fromDate
而是减去 newFrom
或者,在一行中:
var newFrom = this.$store.state.fromDate.clone().subtract(1, 'days');