【问题标题】:tns run android –bundle fails with element not foundtns run android –bundle 失败,找不到元素
【发布时间】:2019-02-14 03:58:48
【问题描述】:

当我使用 tns run android 运行时,我的应用程序运行良好,但是当我使用 tns run android --bundle 时,它给了我以下异常。

找不到元素“nativescript-ui-sidedrawer:RadSideDrawer”的“nativescript-ui-sidedrawer”

我在 bundle-config.js 中看到以下内容。

global.registerModule("nativescript-ui-sidedrawer",
    () => require("../node_modules/nativescript-ui-sidedrawer"));

我尝试在项目中添加/删除 android 平台和插件。我也尝试过提供不同的路径,但没有运气。

global.registerModule("nativescript-ui-sidedrawer",
    () => require("../nativescript-ui-sidedrawer"));

global.registerModule("nativescript-ui-sidedrawer",
    () => require("./nativescript-ui-sidedrawer"));

有人可以帮我吗?

谢谢。

【问题讨论】:

    标签: android webpack bundle nativescript nativescript-cli


    【解决方案1】:

    在您的 XML 文件中(根据我猜测您使用的是 NativeScript Core 而不是基于 Angular 的项目的代码)添加抽屉命名空间,如文档部分 here 中所述。

    <Page xmlns:nsDrawer="nativescript-ui-sidedrawer>
    <!-- page content follows here-->
    </Page>
    

    然后在XML中使用如下:

    <!-- page content follows here-->
    <nsDrawer:RadSideDrawer id="sideDrawer">
    

    【讨论】:

    • 感谢您的回复。这就是我使用它的方式。我可以侧抽屉工作正常。只是当我使用 tns run android --bundle 运行应用程序时,我遇到了这个问题。
    • 对于像 UI 插件这样的自定义组件,您需要为 Wwebpack 手动注册它们,就像这里所做的那样 github.com/telerik/nativescript-ui-samples/blob/release/sdk/app/…
    • 创建 bundle-config.js 文件并通过 registerModule 添加注册插件(您可以从上面的链接复制粘贴文件内容)
    • 我也尝试过,但再次出现以下错误:com.package.app/app/nativescript-ui-sidedrawer' not found for element 'nativescript-ui-sidedrawer:RadSi deDrawer'。找不到模块:“/data/data/com.package.app/files/app/nativescript-ui-sidedrawer”。
    猜你喜欢
    • 1970-01-01
    • 2017-05-27
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 2019-11-29
    相关资源
    最近更新 更多