父组件:

data() {
    return {
      msg: '',
      resType: '',
      interestAlias: '',
    }
  },
  methods: {
    onChange(event) {
      this.resType = event.target.value
      console.log(this.msg)
    },
    getRes() {
      this.msg = [this.resType, this.interestAlias]
      console.log(this.msg)
    },

// 调用子组件
<FlowScheduleResult :msg="msg" />

子组件设置监听:

// 首先定义props
  props: {
    msg: {
      type: Array,
      required: true,
    },
  },

// setup
  setup(props, context) {
    console.log('flow: ' + props.msg)
  },

// 监听数据变化
  watch: {
    msg(newValue, oldValue) {
      console.log('sss:' + newValue)
      if (newValue) {
        this.parentData = newValue
      }
    },
  },

Logo

前往低代码交流专区

更多推荐