แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
blockly > ช่อง > setValidator
เมธอด Field.setValidator()
ตั้งค่าฟังก์ชันการตรวจสอบใหม่สำหรับฟิลด์ที่แก้ไขได้ หรือล้างโปรแกรมตรวจสอบที่ตั้งค่าไว้ก่อนหน้านี้
ฟังก์ชันเครื่องมือตรวจสอบจะใช้ค่าช่องใหม่และแสดงผลค่าที่ตรวจสอบแล้ว ค่าที่ตรวจสอบแล้วอาจเป็นค่าอินพุต ค่าอินพุตเวอร์ชันแก้ไข หรือ Null เพื่อล้มเลิกการเปลี่ยนแปลง
หากฟังก์ชันไม่แสดงผลลัพธ์ใดๆ (หรือแสดงผล "ไม่ระบุ)" จะยอมรับค่าใหม่ว่า "ถูกต้อง" การดำเนินการนี้เป็นการอนุญาตช่องที่ใช้ฟังก์ชันที่ตรวจสอบแล้วเป็นการแจ้งเตือนเหตุการณ์การเปลี่ยนแปลงระดับช่อง
ลายเซ็น:
setValidator(handler: FieldValidator<T>): void;
พารามิเตอร์
พารามิเตอร์ |
ประเภท |
คำอธิบาย |
ตัวแฮนเดิล |
FieldValidator<T> |
ฟังก์ชันตัวตรวจสอบหรือ Null เพื่อล้างโปรแกรมตรวจสอบก่อนหน้า |
การคืนสินค้า:
เป็นโมฆะ
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-08-22 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2024-08-22 UTC"],[[["The `setValidator()` method allows assigning a function to validate user input in editable fields, or removing a previously set validation function."],["Validators receive the new field value and return a validated version, potentially modified or null to reject the change."],["If the validator doesn't return a specific value, the input is accepted, offering a mechanism for change notifications."],["This method is used within Blockly's Field class to ensure data integrity and control user interactions."]]],["The `setValidator()` method configures or removes a validation function for editable fields. This function, provided as a `handler`, receives the new field value and returns either a validated value, a modified value, or `null` to prevent the change. Returning nothing or `undefined` accepts the new value. The `handler` parameter can also be set to `null` to clear an existing validator. It takes a `FieldValidator` type and returns `void`.\n"]]