V
V
Vladimir Golub2021-05-14 13:01:02
Vue.js
Vladimir Golub, 2021-05-14 13:01:02

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

1 answer(s)
A
Aetae, 2021-05-14
@RazerVG

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 question

Ask a Question

731 491 924 answers to any question