tns预览不适用于带有nativescript-vue的android

时间:2018-11-16 09:06:06

标签: nativescript nativescript-vue

我创建了一个超级简单的应用程序,其中包含3个标签和一个通过http呼叫/ axios生成的列表。

当我运行tns run android --bundle时一切正常,但是当我尝试在Android手机上使用游乐场应用程序tns preview时,出现此错误:

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

1 个答案:

答案 0 :(得分:4)

您缺少--bundle命令的tns preview标志。它应该与tns preview --bundle一起使用。

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