Struggling with passing a prop from a parent component down to a child created using CreateElement/render in vue.js and then watching it.
Here is the parent component:
Vue.component('my-drawing', MyDrawing)
new Vue({
el: '#drawing',
mounted() {
Bus.$on('emitColorSelection', (emitString) => {
console.log("inside socket.js/my-drawing and emitString is ", emitString);
this.useColor = emitString;
console.log('inside socket.js/my-drawing and this.useColor after set is ', this.useColor);
})
},
data() {
return {
channel2: null,
canvases: [],
useColor: 'rgba(255, 0, 0, 1)'
}
},
render(createElement) {
return createElement(MyDrawing, {
props: {
useThisColor: this.useColor
}
})
}
});
After assigning the emitted value to useColor
, I aim to pass it on as useThisColor
in the render function.
Now moving on to the child component:
<template>
//my template stuff
</template>
<script>
//stuff
watch: {
useThisColor (n, o) {
console.log("useThisColor watch, ", n, o) // n is the new value, o is the old value.
}
}
//more stuff
The watch tag doesn't seem to output. I've tried placing props in the template and including them in an Updated:
tag, but nothing has worked so far. Any suggestions would be greatly appreciated.