日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)百度小程序教程:swan-sitemap小程序索引頁組件
  • swan-sitemap 小程序索引頁組件
    • 介紹
    • 使用方法
      • 1. 在項目中聲明引用 swan-sitemap 動態(tài)庫
      • 2. 創(chuàng)建一個索引頁頁面,并在頁面中聲明引用 swan-sitemap-list 組件
      • 3. 在頁面代碼中使用 swan-sitemap-list 組件
    • swan-sitemap-list 組件字段詳解
    • 其他開發(fā)要求
    • 展示示例

    swan-sitemap 小程序索引頁組件

    動態(tài)庫,是指可被添加到小程序內(nèi)直接使用的功能組件。開發(fā)者可直接在小程序內(nèi)使用動態(tài)庫,無需重復(fù)開發(fā),為用戶提供更豐富的服務(wù)。更多內(nèi)容參見使用動態(tài)庫。

    創(chuàng)新互聯(lián)建站是專業(yè)的類烏齊網(wǎng)站建設(shè)公司,類烏齊接單;提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行類烏齊網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!

    介紹

    swan-sitemap 動態(tài)庫是百度小程序官方發(fā)布的用于生成小程序索引頁的動態(tài)庫組件,開發(fā)者可以在小程序項目中引用 swan-sitemap 動態(tài)庫,并通過 swan-sitemap-list 組件高效的開發(fā)出符合搜索收錄規(guī)范的小程序索引頁。

    使用方法

    1. 在項目中聲明引用 swan-sitemap 動態(tài)庫

    在 app.json 文件配置的 dynamicLib 字段中增加對 swan-sitemap 的引用,具體格式在使用動態(tài)庫文檔中查看。

    • JSON
     
     
     
    1. "dynamicLib": {
    2. // 'swan-sitemap-lib' 是個可自己定的別名。
    3. "swan-sitemap-lib": {
    4. // provider 是要引用的動態(tài)庫的名字,在此為 'swan-sitemap'。
    5. "provider": "swan-sitemap"
    6. }
    7. }

    2. 創(chuàng)建一個索引頁頁面,并在頁面中聲明引用 swan-sitemap-list 組件

    動態(tài)庫中的組件與其他自定義組件類似,都需要在 page 中使用。所以首先需要創(chuàng)建一個 page,page 路徑可自定義,推薦路徑為 swan-sitemap/index(即在小程序項目根目錄創(chuàng)建 swan-sitemap 文件夾,并在文件夾下創(chuàng)建 index.js、index.swan、index.css、index.json 頁面文件)。

    索引頁上線后,需要在開發(fā)者平臺提交最終的索引頁路徑,具體提交步驟見文檔小程序資源自動同步。

    頁面中引用動態(tài)庫組件的方式是:在頁面的 json 配置的 usingComponents 字段中聲明組件引用。具體格式在使用動態(tài)庫文檔中查看。

    • JSON
     
     
     
    1. "usingComponents": {
    2. "swan-sitemap-list": "dynamicLib://swan-sitemap-lib/swan-sitemap-list"
    3. }

    3. 在頁面代碼中使用 swan-sitemap-list 組件

    swan-sitemap-list 組件需要的具體數(shù)據(jù)及其含義見下節(jié) swan-sitemap-list 組件字段詳解。

    • SWAN
    • JS
     
     
     
    1. list-data="{{listData}}"
    2. current-page="{{currentPage}}"
    3. total-page="{{totalPage}}"
    4. path="/swan-sitemap/index">
     
     
     
    1. Page({
    2. data: {
    3. listData: [],
    4. totalPage: 1,
    5. currentPage: 1,
    6. path: 'swan-sitemap/index'
    7. },
    8. onLoad(e) {
    9. // 初始頁面打開時,需要讀取頁面的 currentPage 參數(shù)(即翻頁頁碼),并根據(jù)參數(shù)值請求數(shù)據(jù)
    10. let {currentPage} = e;
    11. // 起始頁碼為 1,如讀取到的值為空,默認(rèn)賦值起始頁碼
    12. currentPage = +currentPage || 1;
    13. // 根據(jù)當(dāng)前頁碼獲取該頁數(shù)據(jù)資源
    14. this.requestData(currentPage);
    15. },
    16. requestData(currentPage) {
    17. // 發(fā)起數(shù)據(jù)資源請求。
    18. swan.request({
    19. // 數(shù)據(jù)接口,需改為開發(fā)者實際的請求接口
    20. url: sitemapUrl,
    21. data: {
    22. // 參數(shù)中需攜帶頁碼參數(shù),此為示例,可根據(jù)實際情況傳入其他所需參數(shù)
    23. page: currentPage
    24. },
    25. success: res => {
    26. if (+res.data.code === 0) {
    27. let resData = res.data.data;
    28. // 根據(jù)返回數(shù)據(jù)更新列表。如請求返回格式不符合模板數(shù)據(jù) listData 的要求格式,需調(diào)整格式后再賦值給 listData。
    29. // listData 的格式要求為:
    30. // Array<{title:string, path:string, releaseDate:DateString}>,詳見下節(jié) “l(fā)ist-data 項格式說明”
    31. this.setData({
    32. listData: resData.list,
    33. totalPage: resData.totalPage,
    34. currentPage
    35. });
    36. }
    37. }
    38. });
    39. }
    40. });

    swan-sitemap-list 組件字段詳解

    屬性名 類型 是否必填 說明
    list-data Array 當(dāng)前索引頁的小程序資源頁面集合(建議長度 100-200 左右)
    current-page Number 當(dāng)面頁碼
    total-page Number 索引頁總共頁數(shù)
    path String 動態(tài)庫索引頁的 path

    其中 list-data 數(shù)組中的每項為一個 Object,該 Object 具體格式為:

    屬性名 類型 是否必填 說明 示例
    title String 資源頁面標(biāo)題 “第 92 屆奧斯卡金像獎”
    path String 資源頁面路徑(可帶參數(shù)) “/page/article?id=51283431”
    releaseDate String 資源發(fā)布時間(格式為 YYYY-MM-DD HH:mm:ss) “2020-01-01 08:40:06”

    其他開發(fā)要求

    1.【強(qiáng)制】頁面參數(shù)必須有且僅有一個參數(shù) currentPage ,用于指定翻頁頁碼,起始值為 1 。頁面根據(jù) currentPage 參數(shù)展示指定頁資源列表。即一個合法的索引頁 URI 格式為${path}?currentPage=${currentPage}
    2.【強(qiáng)制】需在頁面初始化時(如 onLoad 生命周期)獲取 currentPage 參數(shù),并通過 currentPage 請求當(dāng)頁的數(shù)據(jù)。
    3.【建議】資源列表中每個列表項包含一條資源發(fā)布時間顯示,格式為 YYYY-MM-DD HH:mm:ss 。
    3.【建議】資源列表按照更新日期倒序排列。將較新的資源放在最前面可以提高爬蟲發(fā)現(xiàn)和收錄效率。
    4.【建議】每頁資源條數(shù)在 100-200 左右。

    展示示例


    當(dāng)前題目:創(chuàng)新互聯(lián)百度小程序教程:swan-sitemap小程序索引頁組件
    轉(zhuǎn)載來于:http://m.5511xx.com/article/cdopojs.html