建立工作區
Blockly 工作區是 Blockly 的最高層級元件,這種使用者介面
讓您用區塊編寫程式
如要進一步瞭解工作區及其子元件,請參閱視覺元素
詞彙解釋。
注入 div
您必須將 Blockly 工作區插入至 <div>
(稱為「插入」)
div"。
插入 div 的大小可以靜態調整,或者
動態調整設定。div 中的區塊元素會
會隨著視窗大小調整
下列程式碼片段顯示靜態大小插入 div 的 HTML:
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
注射避孕針
插入功能會建立組成 HTML 子元素 UI 的所有 HTML 子元素
工作區還會執行取得工作區所需的所有初始化作業
立即可用
插入函式可以採用插入 div 的 ID,或是注入式 div 的 ID
div 本身:
// Passes the ID.
const workspace = Blockly.inject('blocklyDiv', { /* config */ });
// Passes the injection div.
const workspace = Blockly.inject(
document.getElementById('blocklyDiv'), { /* config */ });
設定
工作區具有許多選項 (例如版面配置和樣式)
插入的映像檔數量
如要進一步瞭解設定選項,請參閱
設定選項。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-08-22 (世界標準時間)。
[null,null,["上次更新時間:2024-08-22 (世界標準時間)。"],[[["A Blockly workspace is a UI for programming with blocks and is injected into a `\u003cdiv\u003e` element called the injection div."],["The injection div can have static or dynamic sizing, with Blockly elements resizing accordingly."],["Injection creates the workspace UI and initializes it for use, taking either the injection div's ID or the div itself as input."],["Blockly workspaces are highly configurable, allowing you to customize layout, style, and other options during injection."]]],["Blockly workspaces, the UI for block programming, are injected into a designated `\u003cdiv\u003e` element called the \"injection div.\" This div can have a fixed or dynamic size, with Blockly elements resizing accordingly. Injection initializes the workspace UI and readies it for use. The `Blockly.inject()` function, which creates the workspace, accepts either the injection div's ID or the div itself. Workspace configuration, including layout and style, is set during the injection process.\n"]]