truncate
Truncates a string based on provided length.
Installation
Global install:
import Vue from 'vue';
import { truncate } from 'vuetensils/src/filters';
Vue.filter('truncate', truncate);
Local install:
<script>
import { truncate } from 'vuetensils/src/filters';
export default {
filters: {
truncate,
},
};
</script>
Example
<template>
<div>
{{ text | truncate(100) }}
</div>
</template>
<script>
export default {
computed: {
text() {
return 'The sword of Orion hundreds of thousands cosmic ocean as a patch of light the ash of stellar alchemy quasar. Network of wormholes paroxysm of global death vanquish the impossible kindling the energy hidden in matter hydrogen atoms invent the universe.';
},
},
};
</script>