【问题标题】:DropDownList giving an error: this.view is undefinedDropDownList 给出错误:this.view is undefined
【发布时间】:2019-10-06 19:03:08
【问题描述】:

主文件:

<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));
};

关于它为什么抛出这个异常的任何想法?

【问题讨论】:

    标签: apache-royale


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-04
      • 1970-01-01
      • 2020-08-24
      • 2021-08-21
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-25
      相关资源
      最近更新 更多