0

我创建了一个 Nativescript-vue 项目,tns create 我认为从我的 play.nativescript.org 项目中复制了文件:

  • 应用程序/
  • 应用程序.js
  • ..
  • 组件/
    . - 启动.vue
    。---- 文件夹一个/
    . ---- 文件夹OneHome.vue
    。---- 文件夹二/
    。---- folderTwoHome.vue

在我的 app.js 中,我有:

import Vue from "nativescript-vue";
import Startup from "./components/Startup";

new Vue({

    template: `
        <Frame>
            <Startup />
        </Frame>`,

    components: {
        Startup
    }
}).$start();

但我tns preview在 iPhone NativeScript Preview 上运行并获得以下信息:

Executing before-preview-sync hook from /Users/xxxx/projects/private/myapp-mobile/hooks/before-preview-sync/nativescript-dev-webpack.js
Start syncing changes for platform ios.
Copying template files...
Platform ios successfully added. v5.0.0
Executing before-shouldPrepare hook from /Users/xxxx/projects/private/myapp-mobile/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/xxxx/projects/private/myapp-mobile/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Project successfully prepared (ios)
Executing after-prepare hook from /Users/xxxx/projects/private/myapp-mobile/hooks/after-prepare/nativescript-dev-webpack.js
Successfully synced changes for platform ios.
LOG from device xxxx iPhone 8+: 2018-11-11 17:03:53.364 nsplaydev[4353:1286798] ***** Fatal JavaScript exception - application has been terminated. *****
2018-11-11 17:03:53.364 nsplaydev[4353:1286798] Native stack trace:
1   0x100ffff84 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2   0x1010386bc -[TNSRuntime executeModule:referredBy:]
3   0x100d18154 -[UIApplication(PlayLiveSync) swizzled_executeModule:]
4   0x1007b34f4
5   0x1d6ac2bb4 <redacted>
2018-11-11 17:03:53.365 nsplaydev[4353:1286798] JavaScript stack trace:
2018-11-11 17:03:53.365 nsplaydev[4353:1286798] 1   resolveSync@[native code]
2   @[native code]
3   promiseReactionJob@[native code]
2018-11-11 17:03:53.365 nsplaydev[4353:1286798] JavaScript error:
[native code]: JS ERROR Error: Could not find module './components/Startup'. Computed path '/var/mobile/Containers/Data/Application/15C2D576-AEE0-40C4-A8FF-430289A66882/Documents/Playground/LiveSync/app/components/Startup'.
2018-11-11 17:03:53.366 nsplaydev[4353:1286798] PlayLiveSync: Uncaught Exception
2018-11-11 17:03:53.366 nsplaydev[4353:1286798] *** JavaScript call stack:
(

)
2018-11-11 17:03:53.366 nsplaydev[4353:1286798] *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: Could not find module './components/Startup'. Computed path '/var/mobile/Containers/Data/Application/15C2D576-AEE0-40C4-A8FF-430289A66882/Documents/Playground/LiveSync/app/components/Startup'.
 at
1   resolveSync@[native code]
2   @[native code]
3   promiseReactionJob@[native code]  

当我在线运行它时,我得到了我的初始屏幕(Startup.vue),但当我在本地运行它时却没有。对于这样的事情,我是否需要以不同于 Play 的方式编写 Sidekick?

如果重要的话,我升级到 NativeScript 5.0。

另外,我注意到在使用 Visual Studio Code 时,自动完成功能也找不到我的 ./components/Startup.vue,但它确实找到了 ./components 下的所有子目录。

更新:我通过以下方式创建了一个新项目: vue init nativescript-vue/vue-cli-template newTest 然后我 cd 进入该目录并tns preview得到了相同的错误类型:

JS ERROR 错误:找不到模块'./components/App'。

所以这似乎与任何项目无关,而是与如何组装有关?

4

0 回答 0