Skip to main content
Version: 3.x

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.

Reference

Type

(option: Option) => void

Parameters

Option

PropertyTypeRequiredDescription
titlestringYesPage title
keywordsstringYesPage keywords
descriptionstringYesPage description
releaseDatestringNoOriginal release time (year-month-day hour:minute:second with leading zeros)
articleTitlestringNoArticle (content) title.
imagestring | string[]NoImage 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.
videoVideoNoVideo information. Representation of multiple videos in an array
visitVisitNoInformation for visit
likesstringNoThe number of likes, if the page is not counted is empty.
commentsstringNoThe number of comments, if the page is not counted is empty.
collectsstringNoThe number of collects, if the page is not counted is empty.
sharesstringNoThe number of shares, if the page is not counted is empty.
followersstringNoThe number of followers, if the page is not counted is empty.
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

Video

PropertyTypeDescription
urlstringAddress of the video
durationstringDuration of the video (in seconds)
imagestringCover image of the video

Visit

PropertyTypeRequiredDescription
pvstringNoPage views
uvstringNoUnique views
sessionDurationstringNoLength 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

APIWeChat Mini-ProgramBaidu Smart-ProgramH5React Native
Taro.setPageInfo✔️