Created
February 16, 2018 16:16
-
-
Save juanbrujo/639cab15e9adfd008e023ea671dbf15f to your computer and use it in GitHub Desktop.
VueJS 2 Characters left count && limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<textarea v-model="companyDescription"></textarea> | |
Add a comment to this line | |
<p>{{ charactersLeft }}</p> | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
companyDescription: '', | |
maxDescriptionCharacters: 100 | |
} | |
}, | |
computed: { | |
charactersLeft: function () { | |
let char = this.leWord.length | |
const limit = this.limit | |
if (char <= limit) { | |
return (limit - char) + ' / ' + limit + ' caracteres.' | |
} else { | |
this.leWord = this.leWord.substring(0, limit) + '...' | |
return limit + ' / ' + limit + ' caracteres.' | |
} | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The game also offers various modes to enhance your experience, packed with numerous attractive features. Game College Brawl