Taro.setPageInfo(option)
Baidu Smart-Program can access Baidu Search and Baidu App. setPageInfo
is responsible for setting up all kinds of basic page information for the mini program, including title, keywords, page description, as well as image information and video information.By setting page information for the mini program, the developer can help the mini program to be displayed and distributed more effectively in search engines and information flow.
Type
(option: Option) => void
Parameters
Option
Property | Type | Required | Description |
---|---|---|---|
title | string | Yes | Page title |
keywords | string | Yes | Page keywords |
description | string | Yes | Page description |
releaseDate | string | No | Original release time (year-month-day hour:minute:second with leading zeros) |
articleTitle | string | No | Article (content) title. |
image | string | string[] | No | Image online address for cover display after infomercial placement, maximum 3 images, single image maximum 2M; Recommended size of cover image: height>=210px & width>=375px; Minimum size: height>=146px & width>=218px. For multiple images, use an array. |
video | Video | No | Video information. Representation of multiple videos in an array |
visit | Visit | No | Information for visit |
likes | string | No | The number of likes, if the page is not counted is empty. |
comments | string | No | The number of comments, if the page is not counted is empty. |
collects | string | No | The number of collects, if the page is not counted is empty. |
shares | string | No | The number of shares, if the page is not counted is empty. |
followers | string | No | The number of followers, if the page is not counted is empty. |
complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail | (res: any) => void | No | The callback function for a failed API call |
success | (res: Result) => void | No | The callback function for a successful API call |
Video
Property | Type | Description |
---|---|---|
url | string | Address of the video |
duration | string | Duration of the video (in seconds) |
image | string | Cover image of the video |
Visit
Property | Type | Required | Description |
---|---|---|---|
pv | string | No | Page views |
uv | string | No | Unique views |
sessionDuration | string | No | Length of stay per user on the page, in seconds. |
Sample Code
Taro.setPageInfo({
title: 'title',
keywords: 'keywords',
description: 'description',
articleTitle: 'articleTitle',
releaseDate: '2019-01-02 12:01:30',
image: [
'https://c.hiphotos.baidu.com/forum/w%3D480/sign=73c62dda83b1cb133e693d1bed5456da/f33725109313b07e8dee163d02d7912396dd8cfe.jpg',
'https://hiphotos.baidu.com/fex/%70%69%63/item/43a7d933c895d143e7b745607ef082025baf07ab.jpg'
],
video: [{
url: 'https://www.baidu.com/mx/v12.mp4',
duration: '100',
image: 'https://smartprogram.baidu.com/docs/img/image-scaleToFill.png'
}],
visit: {
pv: '1000',
uv: '100',
sessionDuration: '130'
},
likes: '75',
comments: '13',
collects: '23',
shares: '8',
followers: '35',
success: res => {
console.log('setPageInfo success');
},
fail: err => {
console.log('setPageInfo fail', err);
}
})
API Support
API | WeChat Mini-Program | Baidu Smart-Program | H5 | React Native |
---|---|---|---|---|
Taro.setPageInfo | ✔️ |