有没有办法添加mixins的使用

问题描述 投票:1回答:2

考虑一个组件说Articletml文件中使用如下:

<t:article id="id">
    <t:contols model="articleControls" />
</t:article>

tml组件的Article如下:

<article class="app-some-wrapper-class">
  <h2>${title}</h2>
  <h3>${subtile}</h3>
  <body t:mixins="decorator" decorator="shadow" /> <!-- note the use of a mixin here -->
</article>

我需要将mixin应用于<body/>参数,但此实现将抛出ApplicationExpection。这样做的正确方法或替代方法是什么?

tapestry
2个回答
0
投票
<body t:type="any" t:mixins="decorator" decorator="shadow" />

upd:请参阅t5 doc about any:https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/Any.html


0
投票

xl0e的答案是有效的,因为你只能将一个mixin应用到一个挂毯组件(由以t开头的标签标识)只是一个HTML标签,而不是一个挂毯组件。要将mixin应用于它,可以通过添加t:any属性将其转换为tapestry组件。

如果代码写成<t:any element="body" t:mixins="decorator" >...</t:any>可能会更清楚

© www.soinside.com 2019 - 2024. All rights reserved.