微信小程序時(shí)間軸組件的示例代碼
我這里的標(biāo)題是小程序的時(shí)間組件,其實(shí)我這里是將他寫成了一個(gè)頁面,當(dāng)然,如果你有需求,將其做成一個(gè)自定義組件也可以~
這玩意其實(shí)沒有什么技術(shù)難點(diǎn)就是一個(gè)小頁面,我這里就不贅述了。直接上代碼:
Remark.wxml:
<view class="listview-container margin_bottom"> <block wx:for="{{newList}}" wx:key="index"> <view class="playlog-item" > <view class="dotline"> <!-- 豎線 --> <view class="line"></view> <!-- 圓點(diǎn) --> <view class="dot"></view> <!-- 時(shí)間戳 --> </view> <view class="content"> <text class="course">{{item.addtime}}</text> <text class="chapter">{{item.content}}</text> </view> </view> <!-- 廣告插件 --> <!-- <ad unit-id="adunit-5abb45645905fc90" wx:if="{{index % 5 == 4}}"></ad> --> </block> </view>
Remark.js:
//獲取應(yīng)用實(shí)例 const app = getApp(); Page({ /** * 頁面的初始數(shù)據(jù) */ data: { // 數(shù)據(jù)列表 newList:[], }, getData:function(){ var self = this; console.log(self.newList); console.log(self.showText); }, /** * 生命周期函數(shù)--監(jiān)聽頁面加載 */ onLoad: function (options) { }, /** * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成 */ onReady: function () { }, /** * 生命周期函數(shù)--監(jiān)聽頁面顯示 */ onShow: function () { // 監(jiān)聽底部菜單變化 if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 1 // 根據(jù)tab的索引值設(shè)置 }) } var self = this; // 請求后臺(tái)接口獲取隨言碎語列表 wx.request({ // 請求連接 url: 'xxxxxxxxxxxxxxxxxxx', // 請求所需要的的參數(shù) data: {}, success(result){ self.newList = result.data; self.setData({ newList:self.newList, showText: self.showText }) } }); }, /** * 生命周期函數(shù)--監(jiān)聽頁面隱藏 */ onHide: function () { }, /** * 生命周期函數(shù)--監(jiān)聽頁面卸載 */ onUnload: function () { }, /** * 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作 */ onPullDownRefresh: function () { }, /** * 頁面上拉觸底事件的處理函數(shù) */ onReachBottom: function () { }, /** * 用戶點(diǎn)擊右上角分享 */ onShareAppMessage: function () { } })
remark.json
{ "usingComponents": {}, "navigationBarTitleText": "時(shí)間里的-隨言碎語" }
Remark.wxss:
/*外部容器*/ .listview-container { margin: 10rpx 10rpx; margin-bottom: 115rpx; } /*行樣式*/ .playlog-item { display: flex; } /*時(shí)間軸*/ .playlog-item .dotline { width: 35px; position: relative; } /*豎線*/ .playlog-item .dotline .line { width: 1px; height: 100%; background: #ccc; position: absolute; top: 0; left: 15px; } /*圓點(diǎn)*/ .playlog-item .dotline .dot { width: 11px; height: 11px; background: #30ac63; position: absolute; top: 10px; left: 10px; border-radius: 50%; } /*時(shí)間戳*/ .playlog-item .dotline .time { width: 100%; position: absolute; margin-top: 30px; z-index: 99; font-size: 12px; color: #777; text-align: center; } /*右側(cè)主體內(nèi)容*/ .playlog-item .content { width: 100%; display: flex; flex-direction: column; border-bottom: 1px solid #ddd; margin: 3px 0; } /*章節(jié)部分*/ .playlog-item .content .chapter { font-size: 30rpx; line-height: 68rpx; color: #444; white-space: normal; padding-right: 10px; } /*課程部分*/ .playlog-item .content .course { font-size: 28rpx; line-height: 56rpx; color: #999; }
最終效果:
到此這篇關(guān)于微信小程序時(shí)間軸組件的文章就介紹到這了,更多相關(guān)小程序時(shí)間軸組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于javascript實(shí)現(xiàn)日歷功能原理及代碼實(shí)例
這篇文章主要介紹了基于javascript實(shí)現(xiàn)日歷效果原理及代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05js數(shù)組如何添加json數(shù)據(jù)及js數(shù)組與json的區(qū)別
在JSON中,有兩種數(shù)據(jù)結(jié)構(gòu):對象和數(shù)組。本篇文章給大家介紹js數(shù)組如何添加json數(shù)據(jù)以及js數(shù)組和json的區(qū)別,涉及到j(luò)s json數(shù)組添加相關(guān)知識(shí),感興趣的朋友可以參考下本篇文章2015-10-10ES6?Promise.all的使用方法以及其細(xì)節(jié)詳解
Promise對象用于表示一個(gè)異步操作的最終完成(或失敗)及其結(jié)果值,下面這篇文章主要給大家介紹了關(guān)于ES6?Promise.all的使用方法以及其細(xì)節(jié)的相關(guān)資料,需要的朋友可以參考下2022-07-07學(xué)習(xí)JavaScript設(shè)計(jì)模式之中介者模式
這篇文章主要為大家介紹了JavaScript設(shè)計(jì)模式中的中介者模式,對JavaScript設(shè)計(jì)模式感興趣的小伙伴們可以參考一下2016-01-01js實(shí)現(xiàn)可以點(diǎn)擊收縮或張開的懸浮窗
這篇文章主要介紹了js實(shí)現(xiàn)可以點(diǎn)擊收縮或張開的懸浮窗效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09