Elementor 开发者文档

title: "原始 HTML 控件" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Editor Controls - Src - Repos


原始 HTML 控件

Elementor 原始 HTML 控件在面板中显示 HTML 内容。

该控件在继承 Base_UI_Control 类的 Control_Raw_Html 类中定义。

使用此控件时,应将 type 设置为 \Elementor\Controls_Manager::RAW_HTML 常量。

参数

名称 类型 默认值 描述
type string raw_html 控件的类型。
label string 显示在字段上方的标签。
description string 显示在字段下方的描述。
show_label bool true 是否显示标签。
label_block bool false 是否在单独一行显示标签。
separator string default 设置控件分隔符的位置。可用值为 defaultbeforeafterdefault 将隐藏分隔符,除非控件类型有特定的分隔符设置。before / after 将分隔符定位在控件之前/之后。
raw string HTML 标记。
content_classes string 要添加到控件包装器的 CSS 类。

返回值

此控件不返回任何值。

用法

```php {14-22}

start_controls_section( 'content_section', [ 'label' => esc_html__( 'Content', 'textdomain' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'important_note', [ 'label' => esc_html__( 'Important Note', 'textdomain' ), 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => esc_html__( 'A very important message to show in the panel.', 'textdomain' ), 'content_classes' => 'your-class', ] ); $this->end_controls_section(); } } ``` ?>