在我的回复中:
{
"1": [
{
"id": 11,
"seniorcitizen_id": 67201379,
"courier_id": 33,
"totalPrice": 500,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 1,
"medicine_id": 1,
"qty": 3,
"owner": {
"id": 67201379,
"barangay_id": 1,
"first_name": "Cloyd",
"middle_name": "O'Keefe",
"last_name": "Hackett",
"gender": "female",
"mobile": "639153353163",
"telephone": "877-710-3958",
"caretakers_name": "Prof. Laurence Kertzmann",
"caretakers_mobile_phone": "639153353163",
"lat": "10.30431500",
"lng": "123.89035500",
"address": "213 Marlon Forks\nSouth Corineland, HI 81723-1044",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:10",
"updated_at": "2017-10-19 18:09:10"
}
},
{
"id": 12,
"seniorcitizen_id": 67201379,
"courier_id": 33,
"totalPrice": 500,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 1,
"medicine_id": 5,
"qty": 2,
"owner": {
"id": 67201379,
"barangay_id": 1,
"first_name": "Cloyd",
"middle_name": "O'Keefe",
"last_name": "Hackett",
"gender": "female",
"mobile": "639153353163",
"telephone": "877-710-3958",
"caretakers_name": "Prof. Laurence Kertzmann",
"caretakers_mobile_phone": "639153353163",
"lat": "10.30431500",
"lng": "123.89035500",
"address": "213 Marlon Forks\nSouth Corineland, HI 81723-1044",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:10",
"updated_at": "2017-10-19 18:09:10"
}
},
{
"id": 13,
"seniorcitizen_id": 67201379,
"courier_id": 33,
"totalPrice": 500,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 1,
"medicine_id": 6,
"qty": 3,
"owner": {
"id": 67201379,
"barangay_id": 1,
"first_name": "Cloyd",
"middle_name": "O'Keefe",
"last_name": "Hackett",
"gender": "female",
"mobile": "639153353163",
"telephone": "877-710-3958",
"caretakers_name": "Prof. Laurence Kertzmann",
"caretakers_mobile_phone": "639153353163",
"lat": "10.30431500",
"lng": "123.89035500",
"address": "213 Marlon Forks\nSouth Corineland, HI 81723-1044",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:10",
"updated_at": "2017-10-19 18:09:10"
}
}
],
"11": [
{
"id": 18,
"seniorcitizen_id": 67201376,
"courier_id": 33,
"totalPrice": 400,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 11,
"medicine_id": 4,
"qty": 2,
"owner": {
"id": 67201376,
"barangay_id": 1,
"first_name": "Jess",
"middle_name": "Kris",
"last_name": "Berge",
"gender": "female",
"mobile": "93332998610",
"telephone": "(855) 951-3687",
"caretakers_name": "Brad O'Connell",
"caretakers_mobile_phone": "9332998610",
"lat": "10.30309100",
"lng": "123.89154500",
"address": "1291 Stephania Road\nLake Dorotheastad, TN 82682-76",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:09",
"updated_at": "2017-10-19 18:09:09"
}
},
{
"id": 19,
"seniorcitizen_id": 67201376,
"courier_id": 33,
"totalPrice": 400,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 11,
"medicine_id": 5,
"qty": 2,
"owner": {
"id": 67201376,
"barangay_id": 1,
"first_name": "Jess",
"middle_name": "Kris",
"last_name": "Berge",
"gender": "female",
"mobile": "93332998610",
"telephone": "(855) 951-3687",
"caretakers_name": "Brad O'Connell",
"caretakers_mobile_phone": "9332998610",
"lat": "10.30309100",
"lng": "123.89154500",
"address": "1291 Stephania Road\nLake Dorotheastad, TN 82682-76",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:09",
"updated_at": "2017-10-19 18:09:09"
}
}
],
"13": [
{
"id": 21,
"seniorcitizen_id": 67201380,
"courier_id": 33,
"totalPrice": 350,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 13,
"medicine_id": 2,
"qty": 2,
"owner": {
"id": 67201380,
"barangay_id": 1,
"first_name": "Ryann",
"middle_name": "Kub",
"last_name": "Bauch",
"gender": "male",
"mobile": "9332998610",
"telephone": "1-855-475-0137",
"caretakers_name": "Mr. Jarrett Ziemann II",
"caretakers_mobile_phone": "9332998610",
"lat": "10.30356400",
"lng": "123.89964100",
"address": "20330 Schmeler Course Apt. 210\nNorth Ari, NV 70048",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:10",
"updated_at": "2017-10-19 18:09:10"
}
},
{
"id": 22,
"seniorcitizen_id": 67201380,
"courier_id": 33,
"totalPrice": 350,
"delivery_date": "June 14, 2018, 12:00 am",
"packed": 0,
"parcel_id": 13,
"medicine_id": 19,
"qty": 2,
"owner": {
"id": 67201380,
"barangay_id": 1,
"first_name": "Ryann",
"middle_name": "Kub",
"last_name": "Bauch",
"gender": "male",
"mobile": "9332998610",
"telephone": "1-855-475-0137",
"caretakers_name": "Mr. Jarrett Ziemann II",
"caretakers_mobile_phone": "9332998610",
"lat": "10.30356400",
"lng": "123.89964100",
"address": "20330 Schmeler Course Apt. 210\nNorth Ari, NV 70048",
"budget": 1000,
"status": 1,
"dob": "-0001-11-30 00:00:00",
"created_at": "2017-10-19 18:09:10",
"updated_at": "2017-10-19 18:09:10"
}
}
]
}
有这些数据: 我想用lodash映射,如果打包为0则返回false,如果为1,则返回true。
canToggle(){
_.map(this.parcels, function(status) {
var parcelState ;
status.packed === 0 ? parcelState = true : parcelState = false ;
return parcelState ;
});
},
并将其传递给我的组件道具,如:
<delivery-parcel :parcel="parcel" :index="index" :packed="canToggle"></delivery-parcel>
所以在我通过的道具中:它会像:
props: ['packed','index','parcel'],
data(){
return {
isPacked : this.packed
}
并在我的复选框中使用它,以便查看包裹是否已打包,或者不知道该特定包是否已包装。
<v-checkbox @click="togglePacked" v-model="isPacked"></v-checkbox>
答案 0 :(得分:0)
我假设打包将是0或1,而不是任何其他数字。 Vuejs在控制台中分配true和false都有问题,所以我建议这样做。创建一个计算属性,用于检查packed的变量值。
computed: {
packStatus: function () {
return this.packed !== 0 //this should return true if it's not 0, else return false
}
}
然后你可以通过
传递计算方法的返回值<delivery-parcel :parcel="parcel" :index="index" :packed=packStatus></delivery-parcel>