DropDownList给出错误:this.view未定义

时间:2019-10-06 19:03:08

标签: apache-royale

主文件:

<j:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:local="*"
                   xmlns:models="models.*"
                   xmlns:js="library://ns.apache.org/royale/basic"  xmlns:j="library://ns.apache.org/royale/jewel">
    <fx:Script>
        <![CDATA[
            import models.ProductsModel;

            import org.apache.royale.html.DataGrid;

            import products.Product;
            import org.apache.royale.collections.ArrayList;

        ]]>
    </fx:Script>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl />
    </js:valuesImpl>

    <js:initialView >
    <j:View>
    <j:beads>
        <js:ContainerDataBinding/>
    </j:beads>
    <js:model> 
        <models:ListsModel id="listModel" />
    </js:model>

                <j:DropDownList>
                    <j:beads>
                     <js:ConstantBinding
                            sourceID="listModel"
                            sourcePropertyName="ComponentList"
                            destinationPropertyName="dataProvider" />
                    </j:beads>
                </j:DropDownList>
    </j:View>
    </js:initialView>
</j:Application>

我遇到的调试错误: this.view 未定义

此错误指向DropDownListController.js文件中的以下函数:

org.apache.royale.jewel.beads.controllers.DropDownListController.prototype.selectedHandler = function(event) {
  this.model.selectedIndex = (event.index) >> 0;
  this.model.selectedItem = event.data;
  this.view.host.dispatchEvent(new org.apache.royale.events.Event(org.apache.royale.events.Event.CHANGE));
};

关于为什么抛出此异常的任何想法?

1 个答案:

答案 0 :(得分:1)

您是否检查过listModel是否具有ComponentList属性?

尝试使用此代码,它对我而言在SDK 0.9.4和0.9.6上有效

<j:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:local="*"
                   xmlns:models="models.*"
                   xmlns:js="library://ns.apache.org/royale/basic"  xmlns:j="library://ns.apache.org/royale/jewel">
    <fx:Script>
        <![CDATA[
           // import models.ProductsModel;

            import org.apache.royale.html.DataGrid;

            //import products.Product;
            import org.apache.royale.collections.ArrayList;

        ]]>
    </fx:Script>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl />
    </js:valuesImpl>

    <js:initialView >
    <j:View>
    <j:beads>
        <js:ContainerDataBinding/>
    </j:beads>
                <j:DropDownList>
                    <j:dataProvider>
                        <js:ArrayList  source="[Iron Man, Hulk, Thor, Captain America, Hawkeye]" />
                    </j:dataProvider>
                </j:DropDownList>
    </j:View>
    </js:initialView>
</j:Application>