我正在尝试使用vue-clock-picker选择时间。
这是我所做的-
<template>
<div>
<p class="margin-top-30" id="time-section">Timing</p>
<form @submit.prevent="frmStoreTime">
<div class="box-with-radius margin-top-30 clearfix">
<div class="col-sm-12" v-for="(dayVal,index) in days">
<div class="checkbox">
<input :id="'day'+dayVal.id" type="checkbox" @change="manageTiming(dayVal.id,dayVal.day,$event)" :value="dayVal.day" v-model="dayVal.status" />
<label :for="'day'+dayVal.id">{{dayVal.day}}</label>
<div class="space"></div>
</div>
<div class="container" id="app-container" v-show="dayVal.status">
<div class="row" v-for="time, idx in dayVal.times">
<div class="time-slot">
<div class="col-sm-9 col-md-4">
<label for="chkTest">Time</label>
<vue-clock-picker
mode="24" :defaultHour="'12'"
:defaultMinute="'30'"
:onTimeChange="timeChangeHandler" class="form-control form-input start-time" style="padding:0px;height: auto;"
>
</vue-clock-picker>
</div>
<div class="col-sm-3 col-md-4">
<button class="delete-button" type="button" @click="removeSlot(index,idx)">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
<div class="col-sm-12">
<button class="add-more-time-slot" type="button" @click="dayVal.times.push('')">
ADD MORE TIME SLOT
</button>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<button class="btn btn-save" type="submit">SAVE</button>
</div>
</div>
</div>
</div>
</form>
</div>
</template>
脚本:
import VueClockPicker from 'vue-clock-picker'
export default {
name: 'Profile',
components: {
VueClockPicker
},
data() {
return {
days: [{
id: 1,
day: 'MONDAY',
status: false,
times: ['']
},
{
id: 2,
day: 'TUESDAY',
status: false,
times: ['']
},
{
id: 3,
day: 'WEDNESDAY',
status: false,
times: ['']
},
{
id: 4,
day: 'THURSDAY',
status: false,
times: ['']
},
{
id: 5,
day: 'FRIDAY',
status: false,
times: ['']
},
{
id: 6,
day: 'SATURDAY',
status: false,
times: ['']
},
{
id: 7,
day: 'SUNDAY',
status: false,
times: ['']
}
]
}
},
methods: {
timeChangeHandler() {
// ...
},
basicInfoGet() {
var userData = JSON.parse(localStorage.user);
this.$http.get('/api/v1/doctor/basic-info-get', {
headers: {
'x-access-token': localStorage.jwt,
'client-key': userData.client_key,
'Accept': 'application/json'
}
})
.then((response) => {
if (response.data.status == 200) {
let data = response.data.doctorDetails;
var doctorSlots = response.data.doctorSlots;
var defaultDays = this.days;
for (var i = 0; i < defaultDays.length; i++) {
var counter = 0;
for (var j = 0; j < doctorSlots.length; j++) {
if (doctorSlots[j].day_id == defaultDays[i].id) {
defaultDays[i].status = true;
defaultDays[i].times[counter] = doctorSlots[j].time;
counter++;
}
}
}
}
})
},
beforeMount() {
this.basicInfoGet();
}
}
}
作为for循环中的时间选择器组件,因此它创建了多个时间字段。我的问题是,只有“第一次选择器”字段可以正常工作,如果我单击“除第一次选择器”以外的其他字段,那么什么都不会发生,只是无法选择时间。
如何解决这个问题?
任何帮助将不胜感激。
谢谢。