ฉันมีฟิลด์แบบฟอร์มที่มีการเติมข้อความอัตโนมัติทั่วไปดังต่อไปนี้:
<generic-autocomplete
v-model='c.heuristicId'
v-on:change='heuristicSelected(i, $event)'
label='Fuente de datos'
:apiFunction='heuristicsFetchFunction'
:disabled='disabled'/>
เมื่อบันทึกแบบฟอร์มและส่งด้วยฟิลด์นี้ในช่องว่าง heuristicId
gets ส่งเป็น null
ซึ่งเป็นสิ่งที่ต้องการ
อย่างไรก็ตาม เมื่อเลือกค่าจากการเติมข้อความอัตโนมัติทั่วไปแล้วลบออก heuristicId
gets จะถูกส่งไปพร้อมกับ id ของค่าที่เลือกไว้ก่อนหน้านี้
ภายในฟังก์ชันที่เรียก axios ฉันกำลังบันทึก console.log("heuristicId to be sent: " + campaign.heuristicId);
และ undefined
gets เข้าสู่ระบบในทั้งสองสถานการณ์
แก้ไข: หลังจากสอบถามเพิ่มเติมอีกเล็กน้อย ฉันเชื่อว่าข้อผิดพลาดอาจอยู่ในคุณสมบัติการคำนวณอย่างใดอย่างหนึ่งของ <generic-autocomplete/>
:
isValid: function () {
// this checks that the name in display equals the object selected in
// memory so no invalid labels are displayed while a valid object is 'selected'
let vc = this
let result = false
if (vc.object) {
result = vc.objectName === vc.object.name
console.log('generic-autocomplete#isValid', result)
}
return result
}
ค่าว่าง vc.object
จะส่งคืน false
result และฉันไม่สามารถจัดการสิ่งนั้นได้อย่างน่าพอใจ