[Vuejs]-Bound style not applying rapid updates to underlying value

0👍

as it is vuex state, errors.push may not be triggering the change in computed property, You need to do following to make it work:

errors = [...errors, newError]

0👍

Well, using setTimeout() to constrain how quickly new errors are written seems to work. Because in my CSS, the height transition takes 500ms, I don’t think modifying the height again before that 500ms is up works. So I need this code to ensure the array doesn’t change twice within 500ms:

error(context, error) {
    var d = context.state.lastError;
    if (d === null || d < (Date.now() - 500)) {
        context.commit('error', error);
    } else {
        setTimeout(function() {
            context.commit('error', error);
        }, 500);
    }
}

Leave a comment