I have a tuple (or a list) in Python, which works to fill a <select>
control in the Django templates.
The tuple looks like this in Python:
DOCUMENTO_GENERICO = (
(0, 'FUAR y/o Sol. Ind.'),
(1, 'Testimonial'),
(2, 'Instancia administrativa'),
(3, 'Demanda de juicio')
)
But now that I try to use JavaScript, I'm faced with a behavior I can not understand. I made a similar structure in JavaScript:
docs: [
{0: 'Solicitud Individual'},
{1: 'Testimonial'},
{2: 'Instancia administrativa'},
{3: 'Demanda de juicio'}
]
And I use it in the following way:
var app = new Vue({
el: '#app',
data: {
title: 'Tuplas en JavaScrirpt',
docs: [
{0: 'Solicitud Individual'},
{1: 'Testimonial'},
{2: 'Instancia administrativa'},
{3: 'Demanda de juicio'}
]
}
})
<script src="https://unpkg.com/vue"></script>
<div id="app">
{{ title }}
<select name="documento" id="documento">
<option v-for="doc in docs" :value="doc[0]">{{ doc[1] }}</option>
</select>
</div>
I thought that in a line doc
I found a line of docs
, for example {0: 'Solicitud Individual'}
, in Python, I would do something like DOCUMENTO_GENERICO[0][1]
to get Solicitud Individual
, but in JavaScript the result is not as expected.
I want to know what data structure I can use in JavaScript to reproduce the same behavior I use in Python, because this would fix the way I use the <select>
control.