阅读(527) (0)

Laravel 8 命名方式(Casing)

2021-06-28 16:48:18 更新

组件的构造器的参数应该使用 驼峰式 类型,在 HTML 属性中引用参数名时应该使用 烤串式 类型(kebab-case :单词与单词之间使用短横线 - 进行连接)。例如,给定如下的组件构造器:

/**
 * 创建一个组件实例
 *
 * @param  string  $alertType
 * @return void
 */
public function __construct($alertType)
{
    $this->alertType = $alertType;
}

$alertType 参数可以像这样使用:

<x-alert alert-type="danger" />