P
P
petan4ik2018-10-14 12:14:09
Vue.js
petan4ik, 2018-10-14 12:14:09

How to pass props to mixin?

I'm using webpack and single file components, I want to extend a component from a plugin. I do it like this:

import BImgLaze from 'bootstrap-vue/src/components/image/img-lazy'
  export default {
    name: "b-img-lazy-ex",
    extend: BImgLaze,
  }

I am using the component:
<b-img-lazy-ex :src="require('./assets/img/' + img.filename)" center fluid blank-color="#000"/>

The problem is that src and other attributes are not being passed to the component I extended from.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Klein Maximus, 2018-10-15
@kleinmaximus

If you need to use a mixin, then try this :

import BImgLaze from 'bootstrap-vue/src/components/image/img-lazy'
export default {
  name: "b-img-lazy-ex",
  mixins: [BImgLaze],
}

If you just want to extend the component to others, then you need to use extends , not extend .

A
Apkor, 2020-06-19
@Apkor


Props are not properly inherited from mixins / extended components

export default {
  extends: parent,
  props: {...parent.props}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question