setRenderable($renderable); $this->load($load); $this->class($this->elementClass = 'lazy-box'); } /** * 设置是否立即加载. * * @param bool $value * * @return $this */ public function load(bool $value) { $this->load = $value; return $this; } protected function addScript() { $loader = $this->load ? "target.trigger('{$this->target}:load')" : ''; $this->script = <<getElementSelector()}', function (target) { var body = target; {$this->getRenderableScript()} body.html('
').loading(); {$loader} }); JS; } public function html() { $this->addScript(); return <<formatHtmlAttributes()}> HTML; } }