Y
Y
Yura Komarov2020-06-10 23:10:38
Vue.js
Yura Komarov, 2020-06-10 23:10:38

How to add array to data attribute in vue js template?

Hello. I can easily add an array to the data attribute in a php template and get something like this
5ee13cb081e6f187415857.jpeg
. And then I can easily get it using $('.class').data('sizes') and use it in js code.
Tell me, how to achieve the same in the vue template, so that there would also be an array in the data attribute? Now I have when adding an array there using

<div class="w-construc Pos(r)" :data-sizes="item.SIZES">

the output is a string, although I know for sure that the sizes variable contains an array

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2020-06-10
@Yurajun

JSON.stringify(item.SIZES)
Just don't do it that way. You don't need an array in data. Whatever you do with this array, you must do it directly within vue.

A
Alexander Borisovich, 2014-07-20
@Alexey_Gagarin

sitettf.com/fontfiles/a_CampusCaps.php
is very similar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question