Can we pass dynamic props to a Vue mixin from its parent component? Here's the scenario.
This mixin
is set up to receive an isActive
prop.
mixin.ts
export default {
props: {
isActive: {
type: Boolean,
required: true
}
},
watch: {
isActive: {
immediate: true,
handler() {
if (this.isActive) {
// perform some action
} else {
// perform another action
}
}
}
},
methods: {
// additional methods
}
}
This component uses the above mixin.
How can I pass the value of isActiveToBePassed
as the isActive
prop in the mixin?
component.vue
<template>
....
</template>
<script lang="ts">
import mixin from 'mixin';
export default {
name: "Sample",
mixins: [mixin], <- ??? how do I pass the isActiveToBePassed value as a prop?
data() {
return {
isActiveToBePassed: false,
}
},
...
};
</script>
Any suggestions would be appreciated. Thank you.