0

我有一个关于安装 pluin 的问题……尝试了 2 周,但仍然没有得到它。

nativescript-barcodescanner在 {NS}-vue 上使用,在我 npm 安装它之后,我做了rm -rf platform,并添加Vue.registerElement('BarcodeScanner', () => require('nativescript-barcodescanner').BarcodeScannerView)了 app.js 文件。在 Home.vue 中,我添加

<BarcodeScanner
    row="1"
    height="300"
    formats="QR_CODE, EAN_13, UPC_A"
    beepOnScan="true"
    reportDuplicates="true"
    preferFrontCamera="false"
    @scanResult="onScanResult"
    v-if="isIOS">
</BarcodeScanner>

并删除v-if和创建onScanResult方法。并添加import { BarcodeScanner } from "nativescript-barcodescanner";

完成所有操作后,我仍然收到以下错误:

有人可以帮帮我吗?我尝试了很多插件,但仍然失败。(看过一些youtube视频

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.BXBQRCodeScanner/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onCreate failed

TypeError: viewClass is not a constructor
File: "file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js, line: 4225, column: 6

StackTrace: 
    Frame: function:'ElementNode', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8654, column: 24
    Frame: function:'createElement', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8745, column: 12
    Frame: function:'createElement', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8804, column: 23
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5419, column: 79
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13494, column: 10
    Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 17945, column: 15
    Frame: function:'notifyLaunch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39801, column: 15
    Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39734, column: 20
    Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39568, column: 10
    Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 36930, column: 21


    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.tns.NativeScriptException: 
Calling js method onCreate failed

TypeError: viewClass is not a constructor
File: "file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js, line: 4225, column: 6

StackTrace: 
    Frame: function:'ElementNode', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8654, column: 24
    Frame: function:'createElement', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8745, column: 12
    Frame: function:'createElement', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 8804, column: 23
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5419, column: 79
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'createChildren', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5538, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5424, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'init', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 12455, column: 13
    Frame: function:'createComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5452, column: 9
    Frame: function:'createElm', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5401, column: 9
    Frame: function:'patch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5999, column: 7
    Frame: function:'Vue._update', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5025, column: 19
    Frame: function:'updateComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5137, column: 10
    Frame: function:'get', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4220, column: 25
    Frame: function:'Watcher', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 4207, column: 45
    Frame: function:'mountComponent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 5143, column: 3
    Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13478, column: 10
    Frame: function:'', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 13494, column: 10
    Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 17945, column: 15
    Frame: function:'notifyLaunch', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39801, column: 15
    Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39734, column: 20
    Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 39568, column: 10
    Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.BXBQRCodeScanner/files/app/vendor.js', line: 36930, column: 21


    at com.tns.Runtime.callJSMethodNative(Native Method)
    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
    at com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
    at com.tns.Runtime.callJSMethod(Runtime.java:987)
    at com.tns.Runtime.callJSMethod(Runtime.java:967)
    at com.tns.Runtime.callJSMethod(Runtime.java:959)
    at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    ... 11 more

4

2 回答 2

0

您是否使用BarcodeScannera 内的视图,GridLayout因为我看到它具有 的row属性GridLayout

或者尝试插件的演示应用程序,如果它工作链接

于 2019-02-15T15:11:00.513 回答
0
<BarcodeScanner
    row="1"
    height="300"
    formats="QR_CODE, EAN_13, UPC_A"
    beepOnScan="true"
    reportDuplicates="true"
    preferFrontCamera="false"
    @scanResult="onScanResult"
    v-if="isIOS">
</BarcodeScanner>

不能v-if="isIOS"直接删除。
<BarcodeScanner>组件仅在 iOS 中可用。
因此,只需继续v-if="isIOS"使用 Vue 模板代码即可。

于 2019-02-16T15:32:16.000 回答