Trying to get props through visualization in Vue.js and see them

I had a problem with passing the propeller from the parent down through the created child using CreateElement / render in vue.js and then viewing.

Here is my 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
      }
    })
  }
});

So you can see that I accept the emit value for some bus, and then pass that useColor. I would like to pass this value to my rendering function as useThisColor.

Then the baby.

<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.
    }
  } 
//stuff continues

So this watch tag is not displayed. I also tried to put the props in the template without effect, and also try to display it on the tag Updated:. I also tried to set the details in the parent using quotation marks. Nothing has worked so far, and I'm a little confused. If anyone has any ideas please let me know.

+4
1

, , useThisColor, MyDrawing.

.

+2

Source: https://habr.com/ru/post/1677583/


All Articles