百度智能小程序 信息流子項(xiàng)

2020-09-03 16:16 更新

feed-item 信息流子項(xiàng)

解釋: 信息流子項(xiàng),包括左文右圖、純文本、上文下圖、多圖及視頻模式。

屬性說明

屬性名 類型 必填 默認(rèn)值 說明
theme string default 信息流子項(xiàng)的主題:default 是左文右圖模式,如不配置 content 中的 images 則是純文本子項(xiàng);large-image 是大圖模式;multiple-images 是多圖模式
content Object {title: '這個(gè)是子項(xiàng)的標(biāo)題',infoSource: '百度新聞',commentsNum: 2,images: []} 信息流子項(xiàng)目的內(nèi)容,包含標(biāo)題(title),消息來源(infoSource),評論數(shù)(commentsNum),圖片路徑(images)
video Object {isVideo: true, time: '05:00'} 是否為視頻和視頻信息,配置 isVideo 為 true,則顯示視頻形式(注:在多圖模式不生效)
status String 0 閱讀狀態(tài):0 未讀,1 已讀

示例 

在開發(fā)者工具中打開



代碼示例

<view class="smt-feed-item-container">
    <view class="smt-feed-item" s-for="item in cardsList">
        <view s-if="{{loaded}}" class="mode-title">
            <view class="mode-title-line-left"></view>
            <view class="mode-title-text">{{item.name}}</view>
            <view class="mode-title-line-right"></view>
        </view>
        <view class="smt-card-area" >
            <smt-feed-item 
                theme="{{item.config.theme}}"
                content="{{item.config.content}}"
                video="{{item.config.video}}">
            </smt-feed-item>
        </view>   
    </view>
    <view class="smt-card-config" s-if="{{loaded}}">
        <view class="item-scroll" bindtap="navigateTo" hover-class="page-status-hover" hover-stay-time="240">
            <text class="switch-text switch-text-before">查看頁面模板</text>
            <image class="item-logo" src="https://b.bdstatic.com/miniapp/images/extensions/right_arrow.png" rel="external nofollow" ></image>
        </view>
    </view>
</view>
{
    "navigationBarTitleText": "feedItem",
    "navigationStyle": "default",
    "usingComponents": {
        "smt-feed-item": "@smt-ui/component/src/feed-item"
    }
}
Page({
    data: {
        cardsList: [{
            name: '單圖文字模板',
            config: {
                theme: 'default',
                content: {
                    title: '寵物自己在家時(shí), 如何幫助它度過孤獨(dú)時(shí)光',
                    infoSource: '萌寵在家',
                    commentsNum: 183,
                    images: ['https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo1.jpg']
                }
            }
        }, {
            name: '視頻小圖模板',
            config: {
                theme: 'default',
                content: {
                    title: '海洋的最深處到底有什么神奇的生物?',
                    infoSource: '智慧百科',
                    commentsNum: 183,
                    images: ['https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo2.jpg']
                },
                video: {
                    isVideo: true,
                    time: '05:20'
                }
            }
        }, {
            name: '三圖文字模板 ',
            config: {
                theme: 'multiple-images',
                content: {
                    title: '歐洲各地被遺忘的地方,似乎時(shí)間被施了魔法一樣,一切都已經(jīng)停止了',
                    infoSource: '旅行游記',
                    commentsNum: '18.3萬',
                    images: [
                        'https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo3.jpg',
                        'https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo4.jpg',
                        'https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo2.jpg']
                }
            }
        }, {
            name: '大圖文字模板 ',
            config: {
                theme: 'large-image',
                content: {
                    title: '跟貓主子過圣誕節(jié)要什么男朋友,單身朋友的福音',
                    infoSource: '萌寵在家',
                    commentsNum: '18.3萬',
                    images: ['https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo6.jpg']
                }
            }
        }, {
            name: '視頻大圖模板 ',
            config: {
                theme: 'large-image',
                content: {
                    title: '跟貓主子過圣誕節(jié)要什么男朋友,單身朋友的福音',
                    infoSource: '萌寵在家',
                    commentsNum: '18.3萬',
                    images: ['https://spcbj.cdn.bcebos.com/webpkgdev/20200320/KGw3zCAvCXDtSsbcFZsMWlbon2fuPRUZ/v171/extensions/component/resources/smt-feed-item/demo7.jpg']
                },
                video: {
                    isVideo: true,
                    time: '05:20'
                }
            }
        }, {
            name: '純文字模板 ',
            config: {
                theme: 'default',
                content: {
                    title: '2020裝修流行趨勢指南,小戶型也有大空間,簡單實(shí)用',
                    infoSource: '實(shí)用家裝',
                    commentsNum: '18.3萬'
                }
            }
        }]
    },
    onShow() {
        this.setData('loaded', true);
    },
    navigateTo() {
        swan.navigateTo({url: '/extensions/component/smt-feed-page/smt-feed-page'});
    }
});
.smt-feed-item-container {
    margin-top: .2rem;
    padding-bottom: .4rem;
}
.smt-feed-item {
    margin-bottom: .4rem;
}
.smt-card-area {
    margin-top: .14rem;
}
.switch-text-before {
    display: flex;
    align-items: center;
    font-size: 28.986rpx;
    color: #333;
}
.smt-card-config {
    background: #fff;
    overflow: hidden;
}
.item-logo {
    display: inline-block;
    width: 32.609rpx;
    height: 32.609rpx;
    margin: 34.005rpx 0;
}

Bug & Tip

  • Tip: 信息流子項(xiàng)多種模式可以任意組合,模塊間需要使用分割線區(qū)隔。配圖不可清晰度過低,建議標(biāo)題文字不超過 34 個(gè)中文字符。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)