Vue father and son pass values, how to use computed to receive and manipulate data?

how do you use computed to receive and manipulate data when values are passed by father and son?

parent component

// 
<Current
      :status="orderID"
/>
data() {
    return {
      orderID: "",
    };
},
methods: {
  // , 
  getOrderID(orderID) {
    this.orderID = orderID;
  },
},

subcomponents

props: {
    status: {
      type: String,
      default: String,
    },
},
// computed

the child component has passed a value from the parent component successfully
clipboard.png

Apr.08,2022

<template>
  <div>{{statusText}}</div>
</template>

<script>
export default {
  props: {
    status: {
      type: String,
      default: String
    }
  },
  components: {},
  data () {
    return {}
  },
  computed: {
    statusText () {
      console.log(this.status)
      if (this.status === '1234') {
        return ''
      }
    }
  },
  created () {
  },
  methods: {}
}
</script>


computed: {dataGet () {return this.status}}
because you want to use getter, use
the method I have used in template is < div v br model = "dataGet" style= "display:none" > < / div >


sub-component can already obtain statusText data. It is recommended to use vuex to deal with the relevant data in getters.

Menu