แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
การเรียงอันดับ
การทำให้เป็นอนุกรมกำลังบันทึกสถานะของพื้นที่ทำงานเพื่อให้โหลดได้
กลับมาใช้พื้นที่ทำงานในภายหลัง คุณสามารถแปลงข้อมูลทั้งหมดที่ต้องการเพื่อบันทึกลงใน
ซึ่งเป็นรูปแบบข้อความเพื่อให้จัดเก็บได้ง่าย
เราขอแนะนำให้จัดลำดับพื้นที่ทำงานของคุณให้เป็นอนุกรม JSON
สำหรับข้อมูลเพิ่มเติม โปรดดูการทำให้เป็นอนุกรม
บันทึก
ข้อมูลโค้ดต่อไปนี้แสดงวิธีแปลงสถานะของพื้นที่ทำงานเป็น
JSON สำหรับการบันทึก:
// Serialize the state.
const state = Blockly.serialization.workspaces.save(myWorkspace);
// Then you save the state, e.g. to local storage.
localStorage.setItem('workspace-state', state);
โหลด
ข้อมูลโค้ดต่อไปนี้แสดงวิธีโหลดสถานะที่บันทึกไว้บางรายการลงในพื้นที่ทำงาน
// Get your saved state from somewhere, e.g. local storage.
const state = localStorage.getItem('workspace-state');
// Deserialize the state.
Blockly.serialization.workspaces.load(state, myWorkspace);
วิธีนี้จะสร้างองค์ประกอบ ตัวแปร และองค์ประกอบอื่นๆ ที่คุณบันทึกไว้ในองค์ประกอบ
Google Workspace ได้อย่างเต็มประสิทธิภาพ
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-11-04 UTC
[null,null,["อัปเดตล่าสุด 2024-11-04 UTC"],[[["Serialization allows you to save the current state of your Blockly workspace (blocks, variables, etc.) into a text-based format, typically JSON, for later retrieval."],["You can save the serialized workspace data to a storage location like local storage and then load it back into a workspace to restore its previous state."],["Blockly provides APIs (`Blockly.serialization.workspaces.save` and `Blockly.serialization.workspaces.load`) for easily serializing and deserializing workspace states."]]],["Serialization saves workspace states for later loading by converting data into a text-based format, preferably JSON. To save, use `Blockly.serialization.workspaces.save(myWorkspace)` to get the state, then store it (e.g., in local storage). To load, retrieve the saved state and use `Blockly.serialization.workspaces.load(state, myWorkspace)` to recreate blocks, variables, and other elements in the workspace.\n"]]