title: How to use function that return value inside a template? Vuex, Vue
body: <p>I'm using a template to get data of a json file, I use &quot;v-for&quot; to print all data, for example:</p>
  <pre><code>template: /*html*/
      ` 
      &lt;div class=&quot;col-lg-8&quot;&gt;
          &lt;template v-for=&quot;item of actividades&quot;&gt;
              &lt;ul&gt;
                  &lt;li&gt;{{ item.date }}&lt;/li&gt;
              &lt;ul&gt;
          &lt;/template&gt;
      &lt;/div&gt;
      `,
  </code></pre>
  <p>But I need use functions, year() to modificate this information and return and result, for example:</p>
  <pre><code>   template: /*html*/
      ` 
      &lt;div class=&quot;col-lg-8&quot;&gt;
          &lt;template v-for=&quot;item of actividades&quot;&gt;
              &lt;ul&gt;
                  &lt;li&gt;{{ year(item.date) }}&lt;/li&gt;
              &lt;ul&gt;
          &lt;/template&gt;
      &lt;/div&gt;
      `,
  </code></pre>
  <p><strong>The value {{ item.date }} print &quot;2021-01-20&quot; but I hope print &quot;2021&quot; using the function  {{ year(item.date) }}</strong></p>
  <p>Code function year() using javascript:</p>
  <pre><code>year(date){
              return String(date).substr(0, 4);
          }
  </code></pre>
  <p>I tried use that code but is not working, appear this error:
  <img src="https://i.stack.imgur.com/P13th.png" alt="this image show error" /></p>
  <p>That's my javascript code:</p>
  <pre><code>//VueEx
  const store = new Vuex.Store({
      state: {
          actividades: [],
          programas: [],
          year: &quot;&quot;
      },
      mutations: {
          llamarJsonMutation(state, llamarJsonAction){
              state.actividades = llamarJsonAction.Nueva_estructura_proveedor;
              state.programas = llamarJsonAction.BD_programas;
          },
          yearFunction(state, date){
              state.year = String(date).substr(8, 2);
              return state.year;
          }
      },
      actions: {
          llamarJson: async function({ commit }){
              const data = await fetch('calendario-2021-prueba.json');
              const dataJson = await data.json();
              commit('llamarJsonMutation', dataJson);
          }
      }
  });
  
  //Vue
  new Vue({
      el: '#caja-vue',
      store: store,
      created() {
          this.$store.dispatch('llamarJson');
        }
  });
  </code></pre>