Javascript 试图通过Vue.js中的渲染传递道具并观看它们

Javascript 试图通过Vue.js中的渲染传递道具并观看它们,javascript,vue.js,parent-child,state,Javascript,Vue.js,Parent Child,State,我在vue.js中使用CreateElement/render将父对象的道具向下传递给已创建的子对象,然后观察它时遇到了问题 这是我的父组件 Vue.component('my-drawing', MyDrawing) new Vue({ el: '#drawing', mounted() { Bus.$on('emitColorSelection', (emitString) => { console.log("inside socket.js/my-dra

我在vue.js中使用CreateElement/render将父对象的道具向下传递给已创建的子对象,然后观察它时遇到了问题

这是我的父组件

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
      }
    })
  }
});
你们可以看到,这里我取了一些总线的emit值,然后把它传递给useColor。然后,我想将该值作为useThisColor传递给我的渲染函数

孩子来了

<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

//我的模板材料
//东西
观察:{
使用此颜色(n,o){
log(“useThisColor watch,”,n,o)//n是新值,o是旧值。
}
} 
//事情还在继续

所以这个手表标签不输出。我还尝试将道具放在模板中不起作用,并尝试将其输出到
Updated:
标记上。我还尝试使用引号在父对象中设置道具。到目前为止,一切都不顺利,我有点困惑。如果有人有任何想法,请告诉我。

我想这里的问题是您没有在MyDrawing组件上定义属性,
useThisColor


以下是一个。

MyDrawing的道具是什么?顶级MyDrawing父级本身没有道具。它通过一条总线发出,如图所示,未显示的是它从phoenix后端发出对canvases数组的更改(尽管这不会影响此问题)。编辑:当前“我的画”的子对象没有道具,因为它正在使用phoenix修改画布并通过通道发射。所以,现在的问题是通过createElement传递道具并观看它们。MyDrawing组件需要一个名为
useThisColor
。伯特你刚刚创造了我的一天。荣誉,荣誉,荣誉。非常感谢你。