Reputation: 109
I have this data: Sample = [1,2,3]
one input, and and two button
The button are next data and previous
So the idea is to two way bind the input to Sample[var], where var is changeable via the button,
I've been trying to use compute setter or bind the array with changeable var in the data, with no success, what approach should I take?
here's the code:
<ckeditor v-model="thedata"></ckeditor>
data() {
return {
Sample: [1,2,3],
thedata: Sample[var],
var : 0
}
}
Upvotes: 1
Views: 233
Reputation: 339
Let me try to help you. So, you want the value of thedata is based on Sample and var, right?
You can try this code :
<template>
<input v-model="thedata" type="text" />
</template>
<script>
export default {
data() {
return {
Sample: [1, 2, 3],
var: 0,
thedata: '',
};
},
mounted() {
this.thedata = this.Sample[this.var];
},
};
</script>
You can useY mounted()
and then combine the data.
Upvotes: 2
Reputation: 37753
<ckeditor v-model="sample[index]"></ckeditor>
data() {
return {
sample: [1,2,3],
index: 0
}
}
Upvotes: 0