如何在 Apache Royale 上使用 js:DataGrid? Language.synthType 的问题

How to use js:DataGrid on Apache Royale ? Issue with Language.synthType

我在使用此代码时遇到问题,我不知道 Language.synthType 是什么...

使用的SDK是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" 
                   xmlns:binding="org.apache.royale.binding.*"
                   applicationComplete="ev_applicationComplete()">
    <fx:Script>
        <![CDATA[
            import org.apache.royale.collections.ArrayList;



            private function ev_applicationComplete():void {
                dg.dataProvider = new ArrayList( [
                        {label:'Apple',code:'1'},
                        {label:'Nuts',code:'2'}
                    ]);
            }

        ]]>
    </fx:Script>

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

    <js:initialView >
        <j:View>
            <j:beads>
                <js:ContainerDataBinding/>
            </j:beads>

            <js:DataGrid id="dg" width="600" height="300">
                <js:columns>
                    <js:DataGridColumn label="Label" dataField="label" columnWidth="300" />
                    <js:DataGridColumn label="Code" dataField="code"  columnWidth="300"/>
                </js:columns>
            </js:DataGrid>
        </j:View>
    </js:initialView>
</j:Application>

当运行代码抛出这个问题时

EventDispatcher.js:74 Uncaught TypeError: org.apache.royale.utils.Language.synthType is not a function
    at org.apache.royale.html.beads.DataGridView.handleInitComplete (DataGridView.js:88)
    at org.apache.royale.html.DataGrid.goog.events.EventTarget.fireListeners (eventtarget.js:284)
    at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:382)
    at org.apache.royale.html.DataGrid.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
    at org.apache.royale.html.DataGrid.org.apache.royale.events.EventDispatcher.dispatchEvent (EventDispatcher.js:71)
    at org.apache.royale.html.DataGrid.org.apache.royale.core.HTMLElementWrapper.dispatchEvent (HTMLElementWrapper.js:245)
    at org.apache.royale.html.DataGrid.addedToParent (DataGrid.js:58)
    at org.apache.royale.jewel.View.org.apache.royale.core.UIBase.addElement (UIBase.js:414)
    at org.apache.royale.jewel.View.org.apache.royale.core.GroupBase.addElement (GroupBase.js:165)
    at Function.org.apache.royale.utils.MXMLDataInterpreter.org_apache_royale_utils_MXMLDataInterpreter_initializeStrandBasedObject (MXMLDataInterpreter.js:236)

当作为 Class 变量(例如 var intClass:Class = int; <- 您现在可以按预期使用 intClass 来创建一个 int)。

在这种特定情况下,它被用于一些 ' as Class' 类型检查,我们实际上可以在未来的构建中优化掉它(因为它足以做非在 DataGridView 代码中的相关站点中进行 null 检查——这只是额外的解释,如果您有兴趣,请不要担心那个细节)。

所以我能理解问题出在哪里,但我不明白为什么你的 org.apache.royale.utils.Language 副本缺少该功能。您是否有可能将旧版本的语言库与最新的 0.9.6 SDK 混合使用?或者您可能正在使用使用旧版 SDK 编译的库。如果您还没有这样做,我建议您仔细检查 'clean' 构建。 如果您签入调试构建输出,您能否确认以下内容在您的 javascript 控制台中为真:

typeof org.apache.royale.utils.Language.synthType == 'function'

如果您没有看到,那么我认为您的库版本之间一定存在一些冲突,也许某处使用了旧版本的语言库...如果您可以提供更多详细信息,也许我可以提供帮助.