考虑一个组件说Article
在tml
文件中使用如下:
<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
。这样做的正确方法或替代方法是什么?
<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
xl0e的答案是有效的,因为你只能将一个mixin应用到一个挂毯组件(由以t开头的标签标识)只是一个HTML标签,而不是一个挂毯组件。要将mixin应用于它,可以通过添加t:any属性将其转换为tapestry组件。
如果代码写成<t:any element="body" t:mixins="decorator" >...</t:any>
可能会更清楚