"usingComponents": {
"van-search": "@vant/weapp/search/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"van-button": "@vant/weapp/button/index",
"van-grid": "@vant/weapp/grid/index",
"van-grid-item": "@vant/weapp/grid-item/index",
"van-icon": "@vant/weapp/icon/index"
},
<view>
<van-search value="{{ value }}" bind:click-input="onSearch" disabled="{{true}}"/>
view>
<van-tab wx:for="{{ tabData }}" wx:for-item="item" wx:key="id" title="{{item.title}}">
{{item.title}}
van-tab>
Page({
data: {
value: "",
voiceList: [],
},
onLoad() {
let that = this;
// 使用 Mock
ajax({
data: "",
fn: function (res: any) {
//这里既可以获取模拟的res
console.log(res.data);
//修改data里数据
that.setData({ voiceList: res.data });
},
mockConfig: {
"data|50": [
{
"id|+1": 0,
img: "@image('150x100', '#4A7BF7','#fff','pic')",
title: "@ctitle(3,200)",
name: "@cname()",
time: '@datetime(M-dd)',
play: "@float(1,160,0,9)",
icon: "@image('5x10')",
},
],
},
});
}
});
1
2
3
{
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/subregion/subregion",
"pages/my/my",
"pages/components/ChaseItem/ChaseItem",
"pages/levelPage/search/search"
],
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "首页"
},
{
"pagePath": "pages/subregion/subregion",
"text": "分区"
},
{
"pagePath": "pages/my/my",
"text": "我的"
}
]
}
}
<view class="page page-home">
<van-tabs active="{{ active }}" bind:change="onChange">
<van-tab wx:for="{{ tabData }}" wx:for-item="item" title="{{item.title}}">
<hot-item voiceList="{{voiceList}}" wx:if="{{item.title == '热门'}}"/>
<chase-item wx:else/>
van-tab>
van-tabs>
view>
{
"usingComponents": {
"hot-item": "../components/HotItem/HotItem",
"chase-item": "../components/ChaseItem/ChaseItem"
}
}
// pages/components/HotItem/index.ts
Component({
properties: {
// chaseList: { // 属性名
},
data:{
chaseDaysData:[],
btnList:[],
recommendList:[],
active:0
},
observers: {
'chaseDaysData': function(chaseDaysData:any[]) {
console.log('chaseDaysData',chaseDaysData)
}
},
methods:{
imageOnloadError(e:any){
console.log("图片加载出错啦",e)
},
},
ready(){
let that = this;
// 每天番剧
ajax({data:"",fn:function (res:any) {
//这里既可以获取模拟的res
console.log(res.data)
that.setData({chaseDaysData:res.data})
},mockConfig:{
'data|7': [{
'id|+1': 1,
'title|+1': ['一','二','三','四','五','六','日'],
...Mock.mock({
'items|7':[{
'img': "@image('80x80', '#4A7BF7','#fff','pic')",
'title': '@ctitle(4,10)',
}]
})
}]
}});
}
})
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 160rpx;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
详见CSS Grid 网格布局教程
/* 上面 */
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-row-gap: 10rpx;
grid-column-gap: 10rpx;
padding: 10rpx 10rpx;
/* 下面 */
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-row-gap: 10rpx;
grid-column-gap: 10rpx;
padding: 10rpx 10rpx;