1

我创建了一个超级简单的应用程序,它有 3 个选项卡和一个使用 http 调用/axios 生成的列表。

当我运行tns run android --bundle一切正常,但是当我尝试tns preview在我的安卓手机上使用 Playground 应用程序时,我得到了这个错误:

Cannot compile /data/data/org.nativescript.preview/files/app/main.js

SyntaxError: Unexpected identifier
File: "file:///data/data/org.nativescript.preview/files/app/main.js, line: 1, column: 67

StackTrace: 
    Frame: function:'require', file:'', line: 1, column: 266


SyntaxError: Unexpected identifier
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'require', file:'', line: 1, column: 266


    at com.tns.Runtime.runModule(Native Method)
    at com.tns.Runtime.runModule(Runtime.java:553)
    at com.tns.Runtime.run(Runtime.java:545)
    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1028)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5658)
    at android.app.ActivityThread.-wrap2(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:6523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

Executing after-watch hook from /home/badr/projects/ns/annuaire/hooks/after-watch/nativescript-dev-webpack.js
Stopping webpack watch
Executing after-watch hook from /home/badr/projects/ns/annuaire/hooks/after-watch/nativescript-dev-webpack.js
Stopping webpack watch
Executing after-watch hook from /home/badr/projects/ns/annuaire/hooks/after-watch/nativescript-dev-webpack.js
Stopping webpack watch
4

1 回答 1

4

您缺少该命令的--bundle标志。tns preview它应该与tns preview --bundle.

--bundle标志负责运行 webpack,它编译.vue文件。

于 2018-11-16T11:56:36.610 回答