I've got basic template that is outputing text from wysiwyg editor via two-ways data binding as below:
<template>
<div>
<quill-editor
v-model="debounceText"
:options="editorOptionProTemplate"
>
</quill-editor>
<div v-html="textComputed"></div>
</div>
</template>
<script>
data () {
return {
text: ''
}
},
computed: {
debounceText: {
get() { return this.text; },
set: _.debounce(function(newValue) {
this.text = newValue;
}, 100)
},
//using computed for many variants for styling output in web (here just adding <b> tag)
textComputed() {
return '<b>' + this.text + '</b>'
}
}
</script>
at this level all works fine
Now, I'm changing variable into array (object), using v-for (many elemnents to edit at the same time and outputing them in the array as below):
<template>
<div v-for="item in items">
<quill-editor
v-model="item.text"
:options="editorOptionProTemplate"
>
</quill-editor>
<div v-html="textComputedArray"></div>
</div>
</template>
<script>
data () {
return {
items: [
{active: true, text: 'text1', textOutput: ''},
{active: true, text: 'text2', textOutput: ''},
{active: true, text: 'text3', textOutput: ''},
{active: true, text: 'text4', textOutput: ''},
{active: true, text: 'text5', textOutput: ''}
]
}
},
textComputedArray: {
var output=''
for (var i=0; i<this.items.length; i++) {
if (this.items[i].active) {
this.items[i].textOutput= this.items[i].text + '<br />'
output = output + this.items[i].textOutput
}
else {
this.items[i].textOutput= ''
}
}
return output
},
</script>
how should I modify my code to apply debounceText computed to this output? I think that I simply cannot add computed to my template, and also I cannot pass any parameter into computed property.
Maybe someone more experienced than me will give me some solution/advice?