Answer the question
In order to leave comments, you need to log in
How to call a function in a template in a template in Vue?
Hey! I do autocomplete. I want to find occurrences in the list of results and select them.
<li v-for="(item, key) in typeahead.items" :class="'typeahead-list__item ' + activeClass(key)" @mousemove="setActive(key)" @mousedown="hit" v-bind:key="key" v-bind:data-val="item.id">
<div class="typeahead_body">{{ replace(item.city) }}</div>
</li>
replace: function (str) {
return '<strong>Строка</strong>'
}
Answer the question
In order to leave comments, you need to log in
*.html
<li v-for="(item, key) in typeahead.items" :class="'typeahead-list__item ' + activeClass(key)" @mousemove="setActive(key)" @mousedown="hit" v-bind:key="key" v-bind:data-val="item.id">
<div class="typeahead_body">{{ item.city | replace }}</div>
</li>
Vue.filter('replace', function (value) {
// value - это item.city
return '<strong>' + value + '</strong>'
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question