1

主文件:

<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 is undefined

此错误指向 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));
};

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

4

1 回答 1

1

你检查过你listModelComponentList财产吗?

试试这个代码,它在我的 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>
于 2019-10-07T07:30:20.623 回答