Answer the question
In order to leave comments, you need to log in
Is it possible to increase the variable in data inside the template?
<template>
<div>
{{ (() => { count++; return count; })() }}
</div>
</template>
<script>
export default {
data: function() {
return {
count: 0
}
}
}
Answer the question
In order to leave comments, you need to log in
Technically possible, practically impossible. It will be updated every redraw, and in vue you have no control over the redraw, vue redraws itself when it sees fit. You can guess how many and when there will be redraws, because vue doesn't draw too much, but no guarantees.
Well, in general, the template is for display, any changes inside it are a desecration of the very idea.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question