我在NS + Typescript
中有一个项目,并且在其中使用了我们开发的插件,但是我们决定迁移到NS-Vue
,并且在尝试注册组件并使用它时,我们总是得到错误。
在TS项目中,我可以使用通过XML <Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:map="nativescript-notoriun-coletor-plugin" navigatingFrom="onNavigatingFrom" navigatingTo="onNavigatingToMap" loaded="onPageLoaded" >
> System.err: An uncaught Exception occurred on "main" thread.
> System.err: Unable to start activity
> ComponentInfo{org.nativescript.application/com.tns.NativeScriptActivity}:
> com.tns.NativeScriptException: Calling js method onCreate failed
> System.err: Error: [object Object] is not a valid View instance.
> System.err: System.err: StackTrace: System.err:
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{org.nativescript.application/com.tns.NativeScriptActivity}:
> com.tns.NativeScriptException: Calling js method onCreate failed
> System.err: Error: [object Object] is not a valid View instance.
> System.err: at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
> System.err: at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
> System.err: at
> android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
> System.err: at
> android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
> System.err: at
> android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
> System.err: at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
> System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
> System.err: at android.os.Looper.loop(Looper.java:193) System.err:
> at android.app.ActivityThread.main(ActivityThread.java:6680)
> System.err: at java.lang.reflect.Method.invoke(Native Method)
> System.err: at
> com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
> System.err: at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
> System.err: Caused by: com.tns.NativeScriptException: Calling js
> method onCreate failed System.err: Error: [object Object] is not a
> valid View instance. System.err: at
> com.tns.Runtime.callJSMethodNative(Native Method) System.err: at
> com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
> System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
> System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1109)
> System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1089)
> System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1081)
> System.err: at
> com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
> System.err: at android.app.Activity.performCreate(Activity.java:7136)
> System.err: at android.app.Activity.performCreate(Activity.java:7127)
> System.err: at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
> System.err: at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
> System.err: ... 11 more
我在互联网上尝试了几件事,但解决不了
main.js
import Vue from 'nativescript-vue'
import App from './components/App'
Vue.registerElement('EsrimapView', () => require('nativescript-notoriun-coletor-plugin').Esrimap)
import VueDevtools from 'nativescript-vue-devtools'
if(TNS_ENV !== 'production') {
Vue.use(VueDevtools)
}
// Prints Vue logs when --env.production is *NOT* set while building
Vue.config.silent = (TNS_ENV === 'production')
new Vue({
render: h => h('frame', [h(App)])
}).$start()