1

有什么方法可以将静态页面的额外字段中的值提取到某个组件中?

我需要它来实现 AJAX 处理程序......

我可以加载静态页面内容,但我需要获取用户设置的属性...

在此处输入图像描述

我需要一些代码示例...我可以将静态页面内容加载为Partial #noobhacks :)

public function onOpenHome()
{

    $this->page['categories'] = Category::all();

    return [
        //'main' => $this->renderPartial('home'),
        'main' => $this->renderPartial('../content/static-pages/index'),
        '.home_categories' => $this->renderPartial('work_list_categories_post')
    ];
}

或作为内容:

[viewBag]
==
<main class="home_container" __color="{{ color }}">
    <section class="box">
        {% content '/static-pages/index.htm' %} <!-- <<<<------  -->
        {{ content |raw }}
    </section>
</main>

但我不知道如何访问颜色选择器的属性color

4

1 回答 1

2

组件对象可以使用它们的名称(或别名)来使用。这意味着“颜色”的值应该可以通过{{ viewBag.color }}.

于 2017-03-16T22:56:30.620 回答