Following the answer to my debouncing question , I wonder vue.js and lodash/ are underscorecompatible for this feature. Response code
var app = new Vue({
el: '#root',
data: {
message: ''
},
methods: {
len: _.debounce(
function() {
return this.message.length
},
150
)
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.6/vue.js"></script>
<script src="https://unpkg.com/underscore@1.8.3"></script>
<div id="root">
<input v-model="message">Length: <span>{{ len() }}</span>
</div>
Run codeHide resultreally executed when performing my function, when there is continuous input, but when it is finally executed after some inactivity, the input for function()seems to be wrong.
Practical example after running the code above:
- quick sequence of characters, then no action:

- One additional character (
b) is added , and no activity - the length is not updated (but incorrectly, see below).

- Erase all characters with Backspace in quick succession:

- Add one character:

, , message.
, _.debounce vue.js data <input>?
:
lodash, underscore ( debounce throttle).- JSFiddle , SO