我的项目渲染器未找到属性“数据”。
我正在尝试为我的列表创建一个自定义按钮渲染器,但它一直显示未识别的属性“数据”。这是我的代码。
渲染器:
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" label="{data.label}">
</s:Button>
调用渲染器的对象:
<s:List x="80" y="88" width="142" height="384" dataProvider="{navigation}" itemRenderer="com.renderers.NavigationRenderer" borderVisible="false"/>
以及保存列表数据的数组集合:
[Bindable]
private var navigation:ArrayCollection = new ArrayCollection([
{label:"Home",state:"Home"},{label:"Tools",state:"Tools"}
]);
我可能做错了什么?
I'm trying to create a custom button renderer for my list and it keeps saying unidentified property "data." Here is my code.
Renderer:
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" label="{data.label}">
</s:Button>
Object calling the renderer:
<s:List x="80" y="88" width="142" height="384" dataProvider="{navigation}" itemRenderer="com.renderers.NavigationRenderer" borderVisible="false"/>
And the array collection holding the data for the list:
[Bindable]
private var navigation:ArrayCollection = new ArrayCollection([
{label:"Home",state:"Home"},{label:"Tools",state:"Tools"}
]);
What could I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
s:Button 是否有名为 data 的属性?
让您的渲染器扩展 ItemRenderer 类。 更多信息。
你的渲染器应该是这样的:
Does the s:Button have a property named data?
Have your renderer extend the ItemRenderer class. More information here.
Your renderer should be something like this:
Spark 按钮未实现 IDataRenderer 接口。
您可以轻松地将按钮放置在 ItemRenderer 类中以访问该接口,或者您可以创建一个新的项目渲染器类来扩展 Button 并实现 IDataRenderer。
The spark button does not implement the IDataRenderer interface.
You could easily place your button inside an ItemRenderer class to get access to that interface, or you could create a new item renderer class that extends Button and implements IDataRenderer.
默认情况下,Spark 组件没有 data 属性。要将组件用作 inderer,它应该实现 IItemRenderer 接口,而 Spark Button 则没有。
Spark components don't have the data property by default. To use a component as an inderer it should implement the IItemRenderer interface, which the spark Button doesn't.