the following is part of the code in a child component. When assigning a value to amount in the parent component, why the alert pop-up order is" created" = > "init: 1" = > 1 = > "init: 1" = > 2 = > init: 2"= > "init: 2"
data () {
return {
currentLimitType : ""
}
},
watch: {
amount(val) {
alert(1)
if (this.currentLimitType === "") {
this.initData()
}
alert(2)
... //
},
created () {
alert("created")
this.initData()
},
methods: {
async initData() {
alert("init: 1")
const res = await queryOnceLimit() // ajax
alert("init: 2")
this.handlInitData(res, () => {
this.computedCurrentLimitType() // currentLimitType
this.$emit("moneyLimitOk")
})
},