-
Notifications
You must be signed in to change notification settings - Fork 24
Example #6
Comments
let detailPage: WeApp.Page;
Page({
onload: ()=>{
// store the page obj
detailPage = this;
},
onSomeClick: ()=>{
// now you can get intellisence from WeApp.Page from the page interface when pressing the dot key
detailPage.setData({foo:'bar'});
}
}); hope that will help you |
I see I see, it works! Great!
Thanks, |
export class ProfilePage implements PageParam, Page {
setData: (data: any, callback?: Function) => void;
/**
* 页面的初始数据
*/
data: {
imageUrl: null
};
/**
* 生命周期函数--监听页面加载
*/
onLoad(options): void {
let that: WeApp.Page = this; // <---------- here is the trick
if(getApp().globalData.userInfo) {
that.setData({
imageUrl: getApp().globalData.userInfo.avatarUrl
});
}
}
... ... ...
... ... ...
... ... ...
} |
Hi @emeryao , What I really meant is how to use the class definition in some page ts file like your detail-page.ts or my profile.ts... So after finishing up the
As Thanks, |
It spend me a week to understand your requirement up there |
I know its a little bit tweak but its really simple.
Now I need to write the
I found this way of writing works but that's a lot of typing and the deconstruction way doesn't work. The reason I write both
|
Hi @emeryao,
Do you have an example about how to use
interface Page
in coding?Thanks,
John
The text was updated successfully, but these errors were encountered: