封鎖 >Css >插入
Css.inject() 函式
將 CSS 插入 DOM。這比使用一般的 CSS 檔案更適合,因為:a) 檔案會同步載入,而且之後不會強制重新繪製。b) 不會封鎖個別 HTTP 傳輸,藉此加快載入速度。c) CSS 內容可根據 init 選項動態調整。
Signature:
export declare function inject(hasCss: boolean, pathToMedia: string): void;
參數
參數 |
類型 |
說明 |
hasCss |
布林值 |
如果為 false,請勿插入 CSS (提供 CSS 成為文件的責任)。 |
pathToMedia |
字串 |
從網頁到 Blockly 媒體目錄的路徑。 |
傳回:
void
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-12 (世界標準時間)。
[null,null,["上次更新時間:2024-09-12 (世界標準時間)。"],[[["The `Css.inject()` function dynamically adds Blockly's CSS to the webpage, enhancing performance by avoiding a separate HTTP request and redraw."],["This function accepts a boolean `hasCss` flag to control CSS injection and a `pathToMedia` string specifying the location of Blockly's media files."],["Using `Css.inject()` is generally preferred over a traditional CSS file for its synchronous loading, loading speed improvement, and dynamic CSS capability."]]],[]]