I have a Vue Filter to truncate my text when it becomes too long. However, I can not get it to work and have no idea why. Any help welcome.
var app = new Vue({
el: '#app',
data: {
text: 'Bark bark and a woof woof'
}
})
Vue.filter('truncate', function (value, size) {
if (!value) return '';
value = value.toString();
if (value.length <= size) {
return value;
}
return value.substr(0, size) + '...';
});
My HTML is as follows;
<div id="app">
<p>{{text | truncate(8) }}</p>
</div>