错误:Multiple initializers for property 'dataProvider'. (note: 'dataProvider' is the default property of 'mx.controls.LinkBar)
在很多情况下,编译器都会出现这种提示,如:<mx:ToggleButtonBar>,<mx:LinkBar>,<mx:LineChart>
例:
<mx:LinkBar x="10" y="140" dataProvider="{vs}">
<mx:ViewStack id="vs" x="10" y="165">
<mx:Panel label="查看所有用户" title="查看所有用户" width="200" height="100"></mx:Panel>
<mx:Panel label="添加用户" title="添加用户" width="200" height="100"></mx:Panel>
</mx:ViewStack>
</mx:LinkBar>
这种正常的写法,就会出现上述这种错误提示,
解决方法:
把上面代码改成:
<mx:ViewStack id="vs" x="10" y="165">
<mx:Panel label="查看所有用户" title="查看所有用户" width="200" height="100"></mx:Panel>
<mx:Panel label="添加用户" title="添加用户" width="200" height="100"></mx:Panel>
</mx:ViewStack>
<mx:LinkBar x="10" y="140" dataProvider="{vs}"></mx:LinkBar>
即把<mx:ViewStack>放在<mx:LinkBar>后面即可