A
A
asferot2019-02-08 10:08:31
Vue.js
asferot, 2019-02-08 10:08:31

How to use VUE to replace a number with a string?

How to use VUE to replace the number (manager's id) coming from the database with his name? Let's create a filter with the condition, if zayavka.f1740 == 370, then the name will be displayed "Pupkin" for example? Is it possible to implement this, if so, how?
span.manager {{zayavka.f1740}}

computed:{
    ...mapState(['zayavkas']),
    filterZayavka () {
      return this.$store.getters.filterZayavkas
    }
  },
  mounted(){
    this.$store.dispatch('loadZayavka'),
  },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-02-08
@Vlad_IT

Create a dictionary (object) where the key is id and the value is the name of the manager. And just write UPD: but for good, this should happen on the server, there should be a separate "managers" table, with the id, name fields, and the server script should get the manager's name from this table by its id. because it is bad to write such data hard in a script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question