Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript 错误:ActionItem不是有效的视图实例_Nativescript_Angular2 Nativescript_Nativescript Telerik Ui - Fatal编程技术网

Nativescript 错误:ActionItem不是有效的视图实例

Nativescript 错误:ActionItem不是有效的视图实例,nativescript,angular2-nativescript,nativescript-telerik-ui,Nativescript,Angular2 Nativescript,Nativescript Telerik Ui,我有以下模板: <Page.actionBar> <ActionBar title="Modules" automationText="ActionBar"> <NavigationButton icon="res://back_btn" tap="goBack" automationText="GoBack"></NavigationButton> <Android> &

我有以下模板:

<Page.actionBar>
    <ActionBar title="Modules" automationText="ActionBar">
        <NavigationButton icon="res://back_btn" tap="goBack" automationText="GoBack"></NavigationButton>
        <Android>
            <ActionItem id="exampleMenuButton" icon="res://menu" automationText="ExampleMenu"></ActionItem>
        </Android>
        <iOS>
            <ActionItem id="exampleMenuButton" ios.position="right" automationText="ExampleMenu">
                <ActionItem.actionView>
                    <Image src="res://menu" width="22" height="22" margin="0, -11, 0, 11"></Image>
                </ActionItem.actionView>
            </ActionItem>
        </iOS>
    </ActionBar>
</Page.actionBar>

您尝试使用的XML模板是PAN(plainawesomeNativeScript)文件,而不是NAN(NativeScriptagular)文件

事实上,理解这一点非常关键,有些东西只在PAN中起作用,有些东西只在NAN中起作用。它们写得非常相似,但有几个关键的区别

例如,在PAN中它被标记为.XML文件,在NAN中它通常被标记为HTML文件。在PAN中,您有页面标记,在NAN中,您通常跳过页面标记并使用路由器标记。在PAN中,所有标记都可以选择自动关闭。在NAN中,所有标记最好根本不自动关闭

在PAN中,所有事件都被视为xml文件中的任何其他属性;i、 e.
tap=“goback”
。与NAN中的
label=“hi”
相同,点击事件应写成
(点击)=“goback()”

这些只是其中的一小部分差异,还有许多其他的差异使得这两种格式在不更改屏幕的情况下彼此不兼容

既然您似乎正在尝试学习NAN,我建议您签出 示例应用程序。此应用程序完全用NAN编写


此外,还有PAN和NAN应用程序的完整文档。

您尝试使用的XML模板是PAN(plainawesomeNativeScript)文件,而不是NAN(NativeScriptagular)文件

事实上,理解这一点非常关键,有些东西只在PAN中起作用,有些东西只在NAN中起作用。它们写得非常相似,但有几个关键的区别

例如,在PAN中它被标记为.XML文件,在NAN中它通常被标记为HTML文件。在PAN中,您有页面标记,在NAN中,您通常跳过页面标记并使用路由器标记。在PAN中,所有标记都可以选择自动关闭。在NAN中,所有标记最好根本不自动关闭

在PAN中,所有事件都被视为xml文件中的任何其他属性;i、 e.
tap=“goback”
。与NAN中的
label=“hi”
相同,点击事件应写成
(点击)=“goback()”

这些只是其中的一小部分差异,还有许多其他的差异使得这两种格式在不更改屏幕的情况下彼此不兼容

既然您似乎正在尝试学习NAN,我建议您签出 示例应用程序。此应用程序完全用NAN编写


此外,还提供了PAN和NAN应用程序的完整文档。

感谢您的回复,这非常有帮助。实际上,我使用了您提到的示例杂货项目作为我的起点,但我刚刚开始使用Nativescript UI,并没有意识到这些不同的模型,感谢您的澄清!谢谢你的回复,非常有帮助。实际上,我使用了您提到的示例杂货项目作为我的起点,但我刚刚开始使用Nativescript UI,并没有意识到这些不同的模型,感谢您的澄清!
CONSOLE ERROR file:///app/vendor.js:1688:24: ERROR Error: Uncaught (in promise): Error: ActionItem is not a valid View instance.
_addView@file:///app/vendor.js:77124:28 [angular]
addChild@file:///app/vendor.js:79138:22 [angular]
insertChild@file:///app/vendor.js:58553:32 [angular]
appendChild@file:///app/vendor.js:57775:38 [angular]
appendChild@file:///app/vendor.js:13726:34 [angular]
createElement@file:///app/vendor.js:9925:33 [angular]
createViewNodes@file:///app/vendor.js:12532:57 [angular]
callViewAction@file:///app/vendor.js:12944:28 [angular]
execComponentViewsAction@file:///app/vendor.js:12883:27 [angular]
createViewNodes@file:///app/vendor.js:12601:29 [angular]
createRootView@file:///app/vendor.js:12479:20 [angular]
callWithDebugContext@file:///app/vendor.js:13610:47 [angular]
create@file:///app/vendor.js:10415:60 [angular]
createComponent@file:///app/vendor.js:10615:68 [angular]
activateOnGoForward@file:///app/vendor.js:48567:70 [angular]
activateWith@file:///app/vendor.js:48553:37 [angular]
placeComponentIntoOutlet@file:///app/vendor.js:23184:28 [angular]
activateRoutes@file:///app/vendor.js:23165:50 [angular]
file:///app/vendor.js:23101:72 [angular]
forEach@[native code] [angular]
activateChildRoutes@file:///app/vendor.js:23101:36 [angular]
activate@file:///app/vendor.js:23075:33 [angular]
file:///app/vendor.js:22692:30 [angular]
file:///app/vendor.js:230:25 [angular]
...