A
A
Andrej Sharapov2019-08-29 16:02:40
Vue.js
Andrej Sharapov, 2019-08-29 16:02:40

How to correctly pass data to the template?

Good afternoon.
Tell me how to correctly specify the data output in the template, provided that the value can be a string or a number?
Those. if the content is not the amount, but the text
"cost": 1000, // the currency (₽) from the
"cost": "Agreement" template is also added here, // it should not be here
Example (cost):

"table": [
            {
                "title": "Selection",
                "capt": "",
                "cost": 1000,
                "fullcontent": ""
            },
            {
                "title": "1 page",
                "capt": "",
                "cost": "Agreement",
                "fullcontent": ""
            },

In the template I specify:
<h4>{{ p.title }}</h4>
<p><strong>Cost: {{ p.cost }} ₽</strong></p>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Chefranov, 2019-08-29
@Madeas

<span v-for="(p, index) in table" :key="index">
<h4>{{ p.title }}</h4>
<p><strong>Cost: {{ p.cost }} ₽</strong></p>
</span>

and table without quotes in data
data: {
    table:  [...]
  },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question