微信小程序 进入 主页前的 数据加载页面这个页面怎么设置
- 在app.json文件中设置进入小程序时的loading页面,如下所示:
{
"pages": [
"pages/index/index",
"pages/loading/loading"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"loading": {
"text": "加载中...",
"color": "#fff",
"backgroundTextStyle": "dark"
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
}
}
- 在loading页面的wxml文件中添加加载动画和文本提示,如下所示:
<view class="loading">
<image src="/images/loading.gif"></image>
<text>{{text}}</text>
</view>
- 在loading页面的js文件中设置文本提示,如下所示:
Page({
data: {
text: '加载中...'
}
})
- 在loading页面的wxss文件中设置加载动画和文本样式,如下所示:
.loading {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #fff;
}
.loading image {
width: 100rpx;
height: 100rpx;
}
.loading text {
margin-top: 20rpx;
font-size: 28rpx;
color: #999;
}
``
原文地址: https://www.cveoy.top/t/topic/dxgm 著作权归作者所有。请勿转载和采集!