After a parent component sub-assembly to pass a parameter value encountered a problem:
I pass an ID value to the parent component sub-assemblies, subassemblies but after receiving a print created by passing over the life cycle of the life cycle or mounted values are random values, I have not passed over,
The reason is: the front sub-assembly have ID values, and the parent pass over after assembly.
code show as below
父组件 <template> <view> <aaa :id='id'></aaa> </view> </template> <script> data(){ return{ id:19754 } }, onload(){ console.log(''id',this.id) }, method:{ } </script> 子组件 <template> <view> {{id}} </view> </template> <script> props:['id'], data(){}, mounted(){ console.log ( },, this.idid)'id' method: { } </ Script> Solution: fields to monitor passed over by the Watch: the assignment of this field to a new field <Template> <View> {{NEWID}} </ View> </ Template> <Script> The props: [ 'ID' ], Data () { return { NEWID: '' } }, Mounted () { the console.log ( 'ID' , this.idid) }, Watch: { ID: fuction () { the this. = this.id NEWID } the console.log (this.newID) }, Method: { } </ Script>