D
D
Dima Pautov2017-07-20 13:10:30
Vue.js
Dima Pautov, 2017-07-20 13:10:30

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"
  }
]

This is how I create points:
<map-point v-for="point in points" :key="point"></map-point>

This is what the component looks like:
<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>

But I just can't figure out how to correctly set all the properties of the component.
Help me to understand. From the docks, I have not yet figured out how to do it right

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-20
@bootd

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 question

Ask a Question

731 491 924 answers to any question