In vuejs, I need to print text which has style also. I am showing data using v-html and limit 160 characters. If user will click on readmore then more data will show.
Problem is: The below body field has data like this. As starting code has css classes and substring is counting css classes and do not show because 160 characters get finished with in css classes.
"body": "<p style=\"box-sizing: border-box; margin: 0px 0px 10px; text-align: justify; color: #000000; font-family: 'Open Sans'; font-size: 15px;\"><span style=\"box-sizing: border-box;\">Often we can find ourselves stumbling through a day, exhausted. Our work feels draining, our meal times aren’t refreshing, and our nights are spent tossing and turning. This often comes from a lack of balance, and that lack of balance can be corrected if we think of our lives in terms of having three resources available to us.
<div class="col-12 col-lg-4" v-for="item in posts" :key="item.id">
<p v-html="item.body.substring(0, 160) + '...'"></p>
How can I limit characters even css classes are showing also?