Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
152
rated 0 times [  154] [ 2]  / answers: 1 / hits: 47844  / 7 Years ago, mon, october 9, 2017, 12:00:00

I am trying to display a message once the user logs in.


In the case where number of characters exceed 8, how can I display only the first 8 characters of a name followed by ".." ? (Eg: Monalisa..)


new Vue({
el: '#app',
data: {
username: 'AVERYLONGGGNAMMEEE'
}
});

Here is my jsfiddle demo


More From » vue.js

 Answers
3

Here is my answer fiddle : ANSWER-DEMO



<div id=app>
<div v-if=username.length<8>Welcome, {{ username }}</div>
<div v-else>Welcome, {{ username.substring(0,8)+.. }}</div>
</div>

[#56282] Wednesday, October 4, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eddiejoshb

Total Points: 659
Total Questions: 105
Total Answers: 100

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
;