Answer the question
In order to leave comments, you need to log in
How to correctly set properties for a vue.js component?
Good afternoon. I have a component with a vector map, an array with coordinates comes from the admin panel
[
{
id: 1,
lat: 55.75397469,
lng: 37.62079239,
map_x: "28.88888",
map_y: "43.55670",
name: "Москва",
status: "active"
},
{
id: 1,
lat: 55.75397469,
lng: 37.62079239,
map_x: "28.88888",
map_y: "43.55670",
name: "Москва",
status: "active"
}
]
<map-point v-for="point in points" :key="point"></map-point>
<template>
<div
class="point"
:style="{
left: map_x + '%',
top: map_y + '%'
}"
>
<slot></slot>
</div>
</template>
<script src="./mapPoint.js"></script>
<style src="./mapPoint.scss" lang="scss" scoped></style>
Answer the question
In order to leave comments, you need to log in
You can simply pass the whole object with a dot:
You can also like this:
Then in the component you can immediately write props in this form:props['map_x', 'map_y']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question