Browse Source

支持设置组件的 style

xaboy 5 years ago
parent
commit
734076fcaa
1 changed files with 24 additions and 0 deletions
  1. 24 0
      src/Rule/PropsRule.php

+ 24 - 0
src/Rule/PropsRule.php

@@ -30,12 +30,36 @@ trait PropsRule
     protected $attrs = [];
 
     /**
+     * @var string|array
+     */
+    protected $style;
+
+    /**
      * 组件的 DOM 属性
      *
      * @var array
      */
     protected $domProps = [];
 
+    /**
+     * 设置组件的 style 属性
+     * @param string|array $style
+     * @return $this
+     */
+    public function style($style)
+    {
+        $this->style = $style;
+        return $this;
+    }
+
+    /**
+     * @return array|string
+     */
+    public function getStyle()
+    {
+        return $this->style;
+    }
+
     public function prop($name, $value)
     {
         $this->props[$name] = $value;