Description
I'm not sure if this plugin supports vue or the readme provides just the minimal integration. However, I'm running into a strange issue where the text
binding causes Error: Cannot convert object to Ljava/lang/Object; at index 0
In my app.js
, I do the following:
import Vue from 'nativescript-vue'
import MainPage from './components/MainPage'
Vue.registerElement('CheckBox', () => require('./nativescript-checkbox').CheckBox, {
model: {
prop: 'checked',
event: 'checkedChange'
}
})
new Vue({
render: h => h(MainPage)
}).$start()
I have a list of items that are rendered with a component. The components template is:
<template>
<CheckBox :text="item.text" v-model="item.checked" />
</template>
The exception is thrown on Android from this line: https://github.com/nstudio/nativescript-checkbox/blob/master/checkbox.android.ts#L129
Putting some debug statements, I see the following output when the first item is {text: "testValue", checked: false}
.
CheckBox.prototype[exports.textProperty.setNative] = function (value) {
// $> textProperty setNative string {} (default) {}
// $> textProperty setNative testValue (testValue) "testValue"
console.info('textProperty setNative', String(value), Object.getPrototypeOf(value), "(" + value + ")", JSON.stringify(value))
this.nativeView.setText(java.lang.String.valueOf(value));
};
However, when I change my template to the following (i.e., text
is not longer bound and is simply a static attribute), I don't get the exception but I also don't get the desired results.
<template>
<CheckBox text="item.text" v-model="item.checked" />
</template>
When the above template is used, I never get the unexpected {}
or default
value set on the textProperty. What this tells me is either Vue integration with NativeScript has a bug or this plugin. Yet, I'm just starting to play around with NativeStript Vue and so don't have a full grasp. Would definitely appreciate if anyone could shed some light on the issue.