Technology Sharing

The onLoad and onReady events of the uni-app component subcomponent are invalid

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

insert image description here

Table of Contents


Introduction

Suddenly found that in the project, the onLoad and onReady events of the component subcomponents are invalid
What to do if the value cannot be printed?

Solution

insert image description here

	mounted() {
		console.log('onLoad', this.dateList);//有效
		// this.checkinDetails()
	},
	onReady() {
		console.log('onReady', this.dateList);//无效
	},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Finally, the problem was solved by replacing onLoad and onReady with mounted/created.

In the components of uni-app, you can directly use Vue's lifecycle functions to process the logic.

Hello, I am Fei Chen.
Welcome to follow me to obtain front-end learning resources, daily sharing of technological changes, survival rules; industry insider information, and insights into opportunities.