Vueテキストボックス入力文字数制限 2601 ワード watchメソッドを使用 <span> {{this.titleMaxLength - this.title.length}}</span> </div> </template> <script> export default { name: 'Box', data() { return { title: '', titleMaxLength: 60 }; }, methods:{ }, watch: { title() { if (this.title.length > this.titleMaxLength) { this.title = String(this.title).slice(0, this.titleMaxLength); } } } } </script> <style lang="less"> .box{ width: 100%; textarea{ width: 100%; height: 60px; border: none; outline: none; box-sizing: border-box; } } </style> </code></pre> <ul> <li> <ol> <li> </li> </ol> </li> </ul> <pre><code><template> <div class="box"> <textarea v-slicestring="titleMaxLength" v-model="title" width="100%"/> <span> {{this.titleMaxLength - this.title.length >= 0 ?this.titleMaxLength - this.title.length : 0 }}</span> </div> </template> <script> export default { name: 'Box', data() { return { title: '', titleMaxLength: 10, }; }, methods:{ }, directives: { sliceString: { update(el, binding) { if (el.value.length >= binding.value) { el.value = el.value.slice(0, binding.value); } } } } } </script> <style lang="less"> .box{ width: 100%; textarea{ width: 100%; height: 60px; border: none; outline: none; box-sizing: border-box; } } </style> </code></pre> <p> </p> <pre><code> // man.js Vue.directive('limitTextLen', { bind: function () {}, inserted: function () {}, update: function (el, binding) { if (el.value.length >= binding.value) { el.value = el.value.slice(0, binding.value); } }, componentUpdated: function () {}, unbind: function () {} }); </code></pre> </article> </div> </div> EhCacheUtilキャッシュツールクラス Codeforces Round#532(Div.2)E.Andrew and Taxi(二分+トポロジーソート)