A
A
Andrej Sharapov2021-01-12 13:50:54
JavaScript
Andrej Sharapov, 2021-01-12 13:50:54

How to apply Pug array switching in Vue template?

I need to change pug arrays when switching language, but I can't figure out how to apply them.

Массивы:
<template lang="pug">
-
  var activityListRu = [
      {
        i: 'account-switch', 
        t: '1'
      },
      {
        i: 'account-search', 
        t: '2'
      },
      {
        i: 'account-star',
        t: '3'
      }
  ]

-
  var activityListEn = [
      {
        i: 'account-switch', 
        t: '4'
      },
      {
        i: 'account-search', 
        t: '5'
      },
      {
        i: 'account-star',
        t: '6'
      }
  ];
...


Further attempts do not work:

No. 1.
v-row.d-none.d-sm-flex.mb-4
  each card in this.$root.$i18n.locale === "ru" ? activityListRu : activityListEn
    v-col(cols='12', sm='4')
      ...

No. 2. I wanted to write this with a method, but I also don't know how to correctly specify the pug variable in it:
v-row.d-none.d-sm-flex.mb-4
  each card in activityListLocale()
    v-col(cols='12', sm='4')
      ...

methods: {
    activityListLocale() {
      if (this.$root.$i18n.locale === 'ru') {
        return activityListRu
      } else if (this.$root.$i18n.locale === 'en') {
        return activityListEn
      }
    },
  },


Need help from experts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-01-12
@delphinpro

Gloom..
Why not take out arrays in data, make a calculated field and use it normally in a loop?
offtopic, but why even connect a template engine to vue when it is already a template engine for itself?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question