Uni-app, how to realize multiple pages sharing onload

problem description

there is a requirement that you need to execute the same function when multiple pages onload, so I wonder if there is a way to share this function when multiple pages onload.

the environmental background of the problems and what methods you have tried

at present, I am using vue"s mixins way to introduce a common component, common.vue, in which there is an onload function. Then you need to introduce the common.vue component in the page with onload that uses the mixins of vue.

this does enable multiple pages to share the onload of common.vue components, but I have a page that needs to perform other methods when onload. I find that the onload of the page and the component onload introduced by mixins are not merged, and if the page has onload, the onload of the component introduced by mixins is not executed.

what result do you expect? What is the error message actually seen?

is there any way to solve the problem that the onload of the page and the onload of the components introduced by mixins can be executed?

Jun.27,2022

component page does not execute onload can use mounted instead of

Menu