סקר מחקר: נשמח לשמוע על החוויה שלך עם 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);
הפעולה הזו יוצרת את כל הבלוקים, המשתנים והרכיבים האחרים השמורים
סביבת העבודה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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"]]