The problem of the parent component passing the value of Synchronize through props in vue

go straight to the code:

</my-child>
    </div>
    
    // js
    Vue.component("my-child", {
        props: [
          "test"
      ],
      data() {
          return {
            myTest: this.test
        }
      },
      template: "<div>{{ myTest }}</div>"
    })
    new Vue({
      el: "-sharpapp",
      data: {
        test: "test"
      },
      methods: {
          "clickChange" () {
            this.test = "haha"
          console.log(this.test)
        }
      }
    })

when the test passed by the parent component changes, but the myTest assigned to the child component does not change, is there any way to get it quickly? Except for the watch method

Apr.01,2021

you can bind test directly in the subcomponent template or use computed return test; and then bind the calculation property to the template


computed: {
    myTest() {
        return this.test
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb293f-481ae.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb293f-481ae.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?