av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)百度小程序教程:comment-list 評論列表組件

  • comment-list 評論列表組件
    • 屬性說明
      • comment-param 服務參數(shù)說明
      • toolbar-config 參數(shù)說明
      • view-more-style 參數(shù)說明
      • 代碼示例 1:列表組件放入頁面
      • 代碼示例 2:列表支持折疊
    • 調起評論發(fā)布功能
      • 代碼示例:列表組件放入浮層且自定義底部 toolbar
    • Bug & Tip

    comment-list 評論列表組件

    解釋:評論列表,評論的相關數(shù)據(jù)為托管數(shù)據(jù)。
    Web 態(tài)說明:由于瀏覽器的限制,在 Web 態(tài)內(nèi)暫不支持發(fā)布評論、收藏、分享等功能。

    屬性說明

    屬性名類型必填默認值說明
    comment-paramObject評論核心參數(shù)
    toolbar-configObject底部 toolbar 的相關配置
    is-page-scrollBooleantrue滾動方式為頁面滾動,若組件作為浮層使用,該參數(shù)需設為 false
    need-toolbarBooleantrue是否需要底部 toolbar ,若使用開發(fā)者自定義的底部 toolbar ,該參數(shù)需設為 false
    add-commentBooleanfalse用于調起評論發(fā)布器發(fā)布評論
    detail-pathString點擊單條評論跳轉的詳情頁頁面 path ,若沒有配置則不會發(fā)生跳轉;配置的前提是列表與詳情均是頁面級
    is-foldedBooleanfalse是否折疊列表,默認全展示
    fold-numNumber3折疊后列表展示最大條數(shù),默認 3 條,最多 10 條
    view-more-pathString傳入放置評論組件的頁面路徑,如‘/pages/list/index’,組件內(nèi)部會觸發(fā)跳轉邏輯
    view-more-styleObject『全部 xx 條』的樣式,目前只支持開發(fā)者自定義字體顏色
    bindclickcommentEventHandler綁定點擊單條評論的事件,點擊單條評論時觸發(fā),返回數(shù)據(jù)為{status, data:{srid}}
    bindviewmoreEventHandle綁定點擊更多事件,若除了頁面跳轉還需要其他操作,可通過該回調執(zhí)行;若為浮層,也可使用該回調自定義交互邏輯

    comment-param 服務參數(shù)說明

    屬性名類型必填默認值說明示例值
    snidString文章的唯一標識,與 path 參數(shù)一一對應‘20200101’
    titleString文章標題
    pathString智能小程序內(nèi)頁鏈接,最長不能超過 194 字符。如該文章需要入信息流投放,需保證該參數(shù)與信息流投放提交的 path 一致,否則將會影響流量“path”:”/pages/index/index”
    imagesArray數(shù)組第一項用于收藏功能的展示圖片[‘https://b.bdstatic.com/miniapp/images/demo-dog.png‘]

    toolbar-config 參數(shù)說明

    屬性名類型必填默認值說明
    placeholderString輸入框提示文字
    moduleListArray[‘comment’, ‘like’, ‘favor’, ‘share’]顯示的互動模塊,對應默認值分別是:評論數(shù)、點贊、收藏、分享
    shareObject若 moduleList 里配置了 share 模塊,該參數(shù)為必填
    share.titleString分享標題
    share.contentString分享內(nèi)容
    share.imageUrlString分享圖標
    share.pathString頁面 path ,必須是以 / 開頭的完整路徑,如果 path 中參數(shù)包含中文字符,需對中文字符進行編碼

    view-more-style 參數(shù)說明

    屬性名類型必填默認值說明
    colorString‘#3388ff’『全部 xx 條』的字體顏色,默認為視覺提供色號,開發(fā)者可傳入自定義色號

    代碼示例 1:列表組件放入頁面

    頁面中引用動態(tài)庫組件的方式是:在頁面的 json 配置的 usingSwanComponents 字段中聲明組件引用。

    • JSON
     
     
     
    1. {
    2. "navigationBarTitleText": "評論列表",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list"
    5. }
    6. }

    在頁面中放入列表組件,傳入必要的參數(shù)。

    • SWAN
    • JS
     
     
     
    1. comment-param="{{commentParam}}"
    2. detail-path="{{detailPath}}"
    3. toolbar-config="{{toolbarConfig}}"
    4. bindclickcomment="clickComment">
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. detailPath: '/pages/detail/index?params1=abd',
    5. // 底部互動 bar 的配置
    6. toolbarConfig: {
    7. // 若 moduleList 中配置有 share 模塊,默認是有,則該屬性為必填,title 必傳
    8. share: {
    9. title: '測試文章標題'
    10. }
    11. }
    12. },
    13. onLoad(query) {
    14. this.setData({
    15. commentParam: {
    16. snid: '10070000311753961',
    17. path: '/pages/comment/index?snid=test_snid57',
    18. title: '測試文章標題',
    19. content: '測試文章內(nèi)容'
    20. }
    21. });
    22. },
    23. onReady() {
    24. requireDynamicLib('myDynamicLib').listenEvent();
    25. },
    26. clickComment(e) {
    27. }
    28. });

    代碼示例 2:列表支持折疊

    • SWAN
    • JS
    • JSON
    • CSS
     
     
     
    1. {{header.title}}
    2. {{header.author}}
    3. {{header.time}}
    4. {{item.data}}
    5. class="content-img"
    6. src="{{item.data.src}}"
    7. original-src="{{item.data.src}}"
    8. mode="widthFix"
    9. preview="true"
    10. lazy-load="true"/>
    11. comment-param="{{commentParam}}"
    12. is-folded="{{true}}"
    13. fold-num="{{foldNum}}"
    14. toolbar-config="{{toolbarConfig}}"
    15. bindclickcomment="clickComment"
    16. bindviewmore="viewMore">
    17. 歡迎使用智能小程序動態(tài)庫
    18. 歡迎使用智能小程序動態(tài)庫
    19. 歡迎使用智能小程序動態(tài)庫
    20. class="img">
    21. 歡迎使用智能小程序動態(tài)庫
    22. 歡迎使用智能小程序動態(tài)庫
    23. 歡迎使用智能小程序動態(tài)庫
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. header: {
    5. title: '心疼!中國自行車女將卷入摔車事故 腹部扎入3厘米木刺堅持完賽',
    6. avatar: 'https://b.bdstatic.com/miniapp/images/demo-dog.png',
    7. author: '百度智能小程序',
    8. time: '2020年04月14日'
    9. },
    10. content: {
    11. items: [
    12. {
    13. type: 'image',
    14. data: {
    15. src: 'https://b.bdstatic.com/miniapp/images/demo-dog.png'
    16. }
    17. },
    18. {
    19. type: 'text',
    20. data: '測試文字'
    21. }
    22. ]
    23. },
    24. // 折疊展示最大評論條數(shù)
    25. foldNum: 5,
    26. // 底部互動 bar 的配置
    27. toolbarConfig: {
    28. // 若 moduleList 中配置有 share 模塊,默認是有,則該屬性為必填,title 必傳
    29. share: {
    30. title: '心疼!中國自行車女將卷入摔車事故 腹部扎入3厘米木刺堅持完賽'
    31. }
    32. }
    33. },
    34. onLoad(query) {
    35. this.setData({
    36. commentParam: {
    37. snid: '10070000311753961',
    38. path: '/pages/comment/index?snid=test_snid57',
    39. title: '測試文章標題',
    40. content: '測試文章內(nèi)容'
    41. }
    42. });
    43. },
    44. onReady() {
    45. requireDynamicLib('myDynamicLib').listenEvent();
    46. },
    47. clickComment(e) {
    48. swan.showToast({
    49. title: 'click comment success'
    50. });
    51. },
    52. viewMore() {
    53. // swan.showToast({
    54. // title: 'click viewmore success'
    55. // });
    56. }
    57. });
     
     
     
    1. {
    2. "navigationBarTitleText": "折疊列表頁",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list"
    5. }
    6. }
     
     
     
    1. .article-header {
    2. padding: 0 39.8rpx;
    3. }
    4. .article-header .title {
    5. display: block;
    6. font-size: 56rpx;
    7. line-height: 1.5;
    8. font-weight: 700;
    9. }
    10. .article-header .source {
    11. margin-top: 56rpx;
    12. display: flex;
    13. align-items: flex-start;
    14. }
    15. .article-header .source image {
    16. width: 82rpx;
    17. height: 82rpx;
    18. border-radius: 100%;
    19. margin-right: 18.7rpx;
    20. background-color: #eef1f4;
    21. background-size: 37.4rpx 37.4rpx;
    22. background-repeat: no-repeat;
    23. background-position: center center;
    24. background-image: url(../common/assets/logo-default.png);
    25. }
    26. .article-header .info {
    27. display: flex;
    28. flex-direction: column;
    29. justify-content: center;
    30. height: 82rpx;
    31. }
    32. .article-header .info .author {
    33. font-size: 37.4rpx;
    34. line-height: 1;
    35. display: block;
    36. color: #000;
    37. margin-bottom: 16.4rpx;
    38. }
    39. .article-header .info .time {
    40. display: block;
    41. color: #999;
    42. font-size: 28rpx;
    43. line-height: 1;
    44. }
    45. .article-content {
    46. color: #000;
    47. font-size: 44.5rpx;
    48. line-height: 1.58;
    49. letter-spacing: 2.84;
    50. margin-bottom: 70.2rpx;
    51. }
    52. .article-content .content-img {
    53. width: 100%;
    54. margin-top: 70.2rpx;
    55. vertical-align: bottom;
    56. background-color: #eef1f4;
    57. background-size: 74.9rpx 74.9rpx;
    58. background-repeat: no-repeat;
    59. background-position: center center;
    60. background-image: url(../common/assets/logo-default.png);
    61. }
    62. .article-content .content-p {
    63. margin: 57.3rpx 39.8rpx -12.9rpx 39.8rpx;
    64. text-align: justify;
    65. word-break: break-all;
    66. }
    67. .list-after {
    68. padding: 30rpx 18rpx 90rpx;
    69. }
    70. .comment-list-folded-bottom-margin {
    71. height: 14.4rpx;
    72. background-color: #f5f5f5;
    73. }

    調起評論發(fā)布功能

    若開發(fā)者希望調起評論發(fā)布器,且與組件內(nèi)的評論發(fā)布邏輯保持一致(發(fā)布成功插入列表第一條,且滾動到列表頂部),可使用如下方法:
    在 js 文件中,將 add-comment 屬性設為 true ,即可調起評論發(fā)布器。

    前提是評論列表組件已渲染。

    代碼示例:列表組件放入浮層且自定義底部 toolbar

    • SWAN
    • JS
    • JSON
    • CSS
     
     
     
    1. class="img">
    2. 這是背景
    3. 全部評論
    4. class="float-list-component"
    5. add-comment="{{addComment}}"
    6. is-page-scroll="{{false}}"
    7. comment-param="{{commentParam}}"
    8. need-toolbar="{{false}}"
    9. bindclickcomment="clickComment">
    10. 關閉
    11. 評論詳情
    12. class="float-detail-component"
    13. add-comment="{{publishComment}}"
    14. srid="{{srid}}"
    15. is-page-scroll="{{false}}"
    16. comment-param="{{commentParam}}"
    17. need-toolbar="{{false}}"
    18. back-list-after-delete="{{false}}"
    19. binddelete="detailDelete">
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. addComment: {},
    5. showList: false,
    6. showDetail: false,
    7. srid: ''
    8. },
    9. onLoad() {
    10. this.setData({
    11. commentParam: {
    12. snid: '10070000311753961',
    13. path: '/pages/comment/index',
    14. title: '測試文章標題',
    15. 'snid_type': ''
    16. }
    17. });
    18. },
    19. clickComment(e) {
    20. this.setData({
    21. srid: e.data.srid,
    22. showDetail: true,
    23. showList: false
    24. });
    25. },
    26. addComment() {
    27. const showDetail = this.data.showDetail;
    28. if (!showDetail) {
    29. this.setData({
    30. showList: true,
    31. addComment: true
    32. }, () => {
    33. // 需要設為 false 的原因:因為調起發(fā)布監(jiān)聽 addComment 的變化,如果一直為 true,無法再次調起
    34. this.setData({
    35. 'addComment': false
    36. });
    37. });
    38. }
    39. else {
    40. this.setData({
    41. showList: false,
    42. publishComment: true
    43. }, () => {
    44. // 需要設為 false 的原因:因為調起發(fā)布監(jiān)聽 addComment 的變化,如果一直為 true,無法再次調起
    45. this.setData({
    46. 'publishComment': false
    47. });
    48. });
    49. }
    50. },
    51. /**
    52. * 詳情刪除后的回調
    53. *
    54. * @param {Object} options 返回的相關數(shù)據(jù),{status, data}
    55. * @property {string} srid 評論 id
    56. */
    57. detailDelete(options) {
    58. if (options.data.srid) {
    59. this.setData({
    60. showDetail: false,
    61. showList: true
    62. });
    63. }
    64. },
    65. closeDetail() {
    66. this.setData({
    67. showDetail: false,
    68. showList: true
    69. });
    70. }
    71. });
     
     
     
    1. {
    2. "navigationBarTitleText": "智能小程序示例",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list",
    5. "comment-detail": "dynamicLib://myDynamicLib/comment-detail"
    6. }
    7. }
     
     
     
    1. page {
    2. height: 100%;
    3. }
    4. .container {
    5. display: flex;
    6. flex-direction: column;
    7. min-height: 100%;
    8. }
    9. .img {
    10. width: 100%;
    11. position: relative;
    12. z-index: -1;
    13. -webkit-overflow: visible;
    14. }
    15. .bg {
    16. flex: 1;
    17. }
    18. .float-list-wrap,
    19. .float-detail-wrap {
    20. background-color: #fff;
    21. position: fixed;
    22. bottom: 0;
    23. left: 0;
    24. display: block;
    25. height: 900rpx;
    26. animation: climbup .5s;
    27. width: 100%;
    28. z-index: 99;
    29. border-top: 1px solid #666;
    30. border-radius: 10rpx;
    31. }
    32. .float-title {
    33. text-align: center;
    34. padding: 20rpx 0;
    35. }
    36. .float-list-component,
    37. .float-detail-component {
    38. height: 100%;
    39. }
    40. .float-list,
    41. .float-detail {
    42. overflow-y: scroll;
    43. height: 700rpx;
    44. /* my-toolbar 有多高,這里就設多少 */
    45. margin-bottom: 90rpx;
    46. }
    47. .float-detail-close {
    48. float: right;
    49. padding: 20rpx;
    50. }
    51. .my-toolbar {
    52. position: fixed;
    53. bottom: 0;
    54. width: 100%;
    55. height: 90rpx;
    56. background-color: #fff;
    57. z-index: 999;
    58. font-size: 28.99rpx;
    59. }
    60. @keyframes climbup {
    61. /* 因為浮層塊高度為800rpx */
    62. 0% {
    63. height: 0;
    64. }
    65. 25% {
    66. height: 200rpx;
    67. }
    68. 50% {
    69. height: 400rpx;
    70. }
    71. 75% {
    72. height: 600rpx;
    73. }
    74. 100% {
    75. height: 900rpx;
    76. }
    77. }

    Bug & Tip

    • Tip:評論列表數(shù)據(jù)開發(fā)者無法單獨獲取,也無需配置,評論列表會托管給組件,開發(fā)者接入組件之后,用戶評論發(fā)布后會展現(xiàn)在評論列表上(自己可見),審核通過后會全體用戶可見。
    • Tip:openid 和百度 App 登錄狀態(tài)(合稱登錄狀態(tài))會影響用戶的發(fā)布評論、舉報、刪除、消息提醒、跳轉個人主頁和頁面收藏(合稱互動行為),未登錄用戶僅可以瀏覽評論和點贊。
    • Tip:收藏功能在基礎庫 3.190.1 以上可用。
    • Tip:由于 swan.login API 的非兼容改造,一站式互動組件統(tǒng)一改為在組件內(nèi)強登錄。

    網(wǎng)頁題目:創(chuàng)新互聯(lián)百度小程序教程:comment-list 評論列表組件
    網(wǎng)站網(wǎng)址:http://uogjgqi.cn/article/cojgdci.html
    掃二維碼與項目經(jīng)理溝通

    我們在微信上24小時期待你的聲音

    解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流