微信小程序時間軸組件的示例代碼
更新時間:2022年05月31日 10:35:25 作者:camellia
這篇文章主要介紹了微信小程序時間軸組件,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
我這里的標題是小程序的時間組件,其實我這里是將他寫成了一個頁面,當然,如果你有需求,將其做成一個自定義組件也可以~
這玩意其實沒有什么技術難點就是一個小頁面,我這里就不贅述了。直接上代碼:
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>
<!-- 圓點 -->
<view class="dot"></view>
<!-- 時間戳 -->
</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:
//獲取應用實例
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的索引值設置
})
}
var self = this;
// 請求后臺接口獲取隨言碎語列表
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 () {
},
/**
* 頁面相關事件處理函數(shù)--監(jiān)聽用戶下拉動作
*/
onPullDownRefresh: function () {
},
/**
* 頁面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function () {
},
/**
* 用戶點擊右上角分享
*/
onShareAppMessage: function () {
}
})remark.json
{
"usingComponents": {},
"navigationBarTitleText": "時間里的-隨言碎語"
}Remark.wxss:
/*外部容器*/
.listview-container {
margin: 10rpx 10rpx;
margin-bottom: 115rpx;
}
/*行樣式*/
.playlog-item {
display: flex;
}
/*時間軸*/
.playlog-item .dotline {
width: 35px;
position: relative;
}
/*豎線*/
.playlog-item .dotline .line {
width: 1px;
height: 100%;
background: #ccc;
position: absolute;
top: 0;
left: 15px;
}
/*圓點*/
.playlog-item .dotline .dot {
width: 11px;
height: 11px;
background: #30ac63;
position: absolute;
top: 10px;
left: 10px;
border-radius: 50%;
}
/*時間戳*/
.playlog-item .dotline .time {
width: 100%;
position: absolute;
margin-top: 30px;
z-index: 99;
font-size: 12px;
color: #777;
text-align: center;
}
/*右側主體內容*/
.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;
}最終效果:

到此這篇關于微信小程序時間軸組件的文章就介紹到這了,更多相關小程序時間軸組件內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
基于javascript實現(xiàn)日歷功能原理及代碼實例
這篇文章主要介紹了基于javascript實現(xiàn)日歷效果原理及代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-05-05
js數(shù)組如何添加json數(shù)據(jù)及js數(shù)組與json的區(qū)別
在JSON中,有兩種數(shù)據(jù)結構:對象和數(shù)組。本篇文章給大家介紹js數(shù)組如何添加json數(shù)據(jù)以及js數(shù)組和json的區(qū)別,涉及到js json數(shù)組添加相關知識,感興趣的朋友可以參考下本篇文章2015-10-10
ES6?Promise.all的使用方法以及其細節(jié)詳解
Promise對象用于表示一個異步操作的最終完成(或失敗)及其結果值,下面這篇文章主要給大家介紹了關于ES6?Promise.all的使用方法以及其細節(jié)的相關資料,需要的朋友可以參考下2022-07-07

