Constantinius
Constantinius

Reputation: 35089

Passing data to components in slots

Background: I'd like to create a Vue.js wrapper for openlayers. I had in mind that the API can be used like this:

<mv-map :center="..." :zoom="..." :projection="...">
  <mv-layer ...>
    <mv-source ...>
      ...
    </mv-source>
  </mv-layer>
</mv-map>

I'd love to keep this kind of open interface, as layers can potentially be nested.

My problem is that I create an ol.Map object in the mv-map component that I somehow have to access in the mv-layer component, but I cannot pass it there, because mv-layer is added to the slot.

I tried to use this.$parent.$get(...) in mv-layer but that somehow "is not a function".

How to I either pass down data from parent components to slotted components or access parent data in slotted components?

Upvotes: 3

Views: 478

Answers (1)

Bert
Bert

Reputation: 82489

You can use this.$parent.<property>.

Example.

Upvotes: 1

Related Questions