compontent time duration 交互影響, 關聯性待修.
This commit is contained in:
@@ -5,12 +5,13 @@
|
||||
<p>min: {{ timeData.min }}</p>
|
||||
<p>max: {{ timeData.max }}</p>
|
||||
<div class="flex justify-between items-center">
|
||||
<Durationjs></Durationjs>
|
||||
<span>~</span>
|
||||
<Durationjs></Durationjs>
|
||||
<!-- <Durationjs :max="max" :min="min" :size="'min'" @total-seconds="minTotalSeconds"></Durationjs>
|
||||
<span>~</span>
|
||||
<Durationjs :max="max" :min="min" :size="'max'" @total-seconds="maxTotalSeconds"></Durationjs> -->
|
||||
<Durationjs :max="minVuemax" :min="minVuemin" :size="'min'" ></Durationjs>
|
||||
<span>~</span>
|
||||
<Durationjs :max="maxVuemax" :min="maxVuemin" :size="'max'" ></Durationjs>
|
||||
</div>
|
||||
<!-- <Durationjs></Durationjs> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -22,47 +23,50 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
timeData: {
|
||||
min: null,
|
||||
max: null,
|
||||
min: 0,
|
||||
max: 0,
|
||||
},
|
||||
selectTimeRange: [20, 80],
|
||||
selectedStart: null,
|
||||
selectedEnd: null,
|
||||
timeStart: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'],
|
||||
timeEnd: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'],
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Durationjs,
|
||||
},
|
||||
watch: {
|
||||
time: function(newValue, oldValue) {
|
||||
this.timeData = {
|
||||
min: newValue.min,
|
||||
max: newValue.max
|
||||
}
|
||||
computed: { // 一定得用 computed 傳遞資料,不要拿父元件 props 的數值,不然子元件會交互影響。
|
||||
minVuemin() {
|
||||
return this.time ? this.time.min : 0;
|
||||
},
|
||||
minVuemax() {
|
||||
return this.time ? this.time.max : 0;
|
||||
},
|
||||
maxVuemin() {
|
||||
return this.time ? this.time.min : 0;
|
||||
},
|
||||
maxVuemax() {
|
||||
return this.time ? this.time.max : 0;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.selectedStart = this.timeStart[1];
|
||||
this.selectedEnd = this.timeEnd[5];
|
||||
watch: {
|
||||
time: function(newValue, oldValue) {
|
||||
if(newValue == null) {
|
||||
this.timeData = {
|
||||
min: 0,
|
||||
max: 0
|
||||
};
|
||||
}else if(newValue != null) {
|
||||
this.timeData = {
|
||||
min: newValue.min,
|
||||
max: newValue.max
|
||||
};
|
||||
};
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
minTotalSeconds(e) {
|
||||
// console.log('min:', e);
|
||||
},
|
||||
maxTotalSeconds(e) {
|
||||
// console.log('max:', e);
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.time-preview {
|
||||
border: 1px solid #eee;
|
||||
max-width: 400px;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
margin-bottom: 20px;
|
||||
padding: 15px;
|
||||
background: rgb(70, 25, 173);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.time-preview-time {
|
||||
font-size: 30px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user