How does Mini Program get the page object of the current page

The instance of

app is getApp ()

how can I get the current instance of page?

var page = Page ({})

is this all right? Or is it in some other way


get it directly with this in the function defined in the page object;

or:

var pages = getCurrentPages()    //
var currentPage = pages[pages.length-1]    //

you can test it with the following code:

Page({
    onLoad:function(){
        var pages = getCurrentPages()    //
        var currentPage = pages[pages.length - 1]    //
        console.log("page:")
        console.log(currentPage===this)    //true
    }
})
Menu