1、项目目录如下图,utils目录下的文件和main.js文件在下面可以直接下载使用
2、demo案例,前端代码
php;gutter:true;
export default {
data() {
return {
// 轮播图初始化数据
banner: [],
current: 0,
circular: true,
autoplay: true,
interval: 3000,
duration: 800,
}
},
onLoad() {
getBanner(this);
}
}
// 请求轮播图接口
function getBanner(that){
that.$http.httpGet('/v1/app.php',{
type: 'banner',
}).then((res) => {
var shopsInfo = [];
for (var i = 0; i < res.data.length; i++) {
shopsInfo.push({
url: that.$config.uni_app_web_url + res.data[i].litpic
});
}
that.banner = shopsInfo;
}).catch((error) => {
console.log(error);
});
}</p>
<pre><code>.wrap {
padding: 10rpx 10rpx;
}
/* 轮播样式 &&&&&& 开始 */
.index-swiper {
position: relative;
width: 96%;
margin-left: 2%;
border-radius: 10rpx;
overflow: hidden;
}
.lunbo_navigator {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
.slide-image{
width: 100%;
height: 100%;
border-radius: 10rpx;
}
</code></pre>
<pre><code>
3、后端代码示例
;gutter:true;
where(‘banner’,1)->select();
return json(array(‘code’ => 0,"msg" => "获取成功!","data" => $res));
}
?>
Original: https://www.cnblogs.com/xiaofengzheng/p/16424346.html
Author: 小风筝666
Title: uniapp封装request请求,常用公共函数等,非常实用
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/582111/
转载文章受原作者版权保护。转载请注明原作者出处!