Bản khảo sát nghiên cứu: Cho chúng tôi biết trải nghiệm của bạn khi sử dụng Blockly
Bắt đầu khảo sát
Nhà cung cấp không đổi
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
ConstantProvider
là một tập hợp các số ma thuật, hình dạng và chuỗi được sử dụng bởi tất cả các thành phần kết xuất khác, cũng như các phần khác của Blockly, như các trường tích hợp sẵn.
Tất cả các giá trị hằng số đều được giả định là hằng số! Việc thay đổi giá trị trong thời gian chạy sẽ gây ra lỗi kết xuất.
Hình dạng kết nối
Trình cung cấp hằng số chứa các định nghĩa cho hình dạng tiêu chuẩn của các kết nối khác nhau. Notch
xác định hình dạng của các kết nối tiếp theo và trước đó. PuzzleTab
xác định hình dạng của các kết nối đầu vào và đầu ra. (Những tên này dựa trên các hình dạng do trình kết xuất mặc định cung cấp).
Hình dạng kết nối dựa trên các bước kiểm tra
Trình cung cấp hằng số cũng có thể xác định hình dạng của các kết nối một cách linh động dựa trên quy trình kiểm tra kết nối. Bạn có thể thực hiện việc này bằng cách sử dụng phương thức shapeFor
.
Nhiều lộ trình khác
Trình cung cấp hằng số cũng xác định đường dẫn cho nhiều phần khác của khối, như các cạnh lởm chởm cho các khối được thu gọn.
Các giá trị khác nhau
Cuối cùng, trình cung cấp hằng số cũng xác định nhiều giá trị cho những mục như khoảng đệm giữa các thành phần hoặc chiều cao tối thiểu của các hàng.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eConstantProvider\u003c/code\u003e stores essential values like shapes, strings, and numbers used by Blockly's rendering components.\u003c/p\u003e\n"],["\u003cp\u003eIt defines standard shapes for different connection types, including notches for previous/next connections and puzzle tabs for input/output connections.\u003c/p\u003e\n"],["\u003cp\u003eConnection shapes can be dynamically determined based on connection checks using the \u003ccode\u003eshapeFor\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eConstantProvider\u003c/code\u003e also defines paths for elements like collapsed block edges and various values for padding and minimum heights.\u003c/p\u003e\n"],["\u003cp\u003eModifying \u003ccode\u003eConstantProvider\u003c/code\u003e values during runtime is discouraged as it can lead to rendering issues.\u003c/p\u003e\n"]]],["The `ConstantProvider` stores essential rendering data for Blockly, including connection shapes, paths, and values. It defines standard connection shapes like `Notch` for next/previous connections and `PuzzleTab` for input/output. The `shapeFor` method allows dynamic shape definition based on connection checks. Additionally, it defines paths for block components, like jagged edges, and values for padding and minimum row heights, ensuring consistent rendering. Changing these values at runtime will cause rendering issues.\n"],null,["# Constant provider\n\nThe [`ConstantProvider`](/blockly/reference/js/blockly.blockrendering_namespace.constantprovider_class) is a collection of magic numbers,\nshapes and strings used by all of the other renderer components, as well as\nother parts of Blockly like the built-in fields.\n\nAll constant values are assumed to be *constant*! Changing values at\nruntime causes rendering bugs.\n\nConnection shapes\n-----------------\n\nThe constant provider contains definitions for the standard shapes of different\nconnections. [`Notch`](/blockly/reference/js/blockly.blockrendering_namespace.constantprovider_class.notch_property)es define the shapes of next and previous\nconnections. And the [`PuzzleTab`](/blockly/reference/js/blockly.blockrendering_namespace.constantprovider_class.puzzle_tab_property)s define the shapes of input\nand output connections. (These names are based on the shapes provided by\nthe default renderer.)\n\n### Connection shapes based on checks\n\nThe constant provider can also define the shapes of connections dynamically\nbased on their [connection check](/blockly/guides/create-custom-blocks/type-checks). This is done using the\n[`shapeFor`](/blockly/reference/js/blockly.blockrendering_namespace.constantprovider_class.shapefor_1_method) method.\n\nOther various paths\n-------------------\n\nThe constant provider also defines paths for other various parts of the\nblock, like jagged edges for collapsed blocks.\n\nOther various values\n--------------------\n\nAnd finally, the constant provider also defines various values for things like\nthe padding between different elements, or the minimum heights of rows."]]