搜索栏和轮播图

This commit is contained in:
jqtmviyu@gmail.com 2021-02-21 08:56:49 +08:00
parent c1b1c07c5a
commit 9671a7e3f4

View File

@ -1,6 +1,15 @@
<template> <template>
<view class="content"> <view class="content">
<u-button>默认按钮</u-button> <!-- 1.搜索栏 -->
<view class="search">
<u-search placeholder="搜索" :show-action="false"></u-search>
</view>
<!-- 2.轮播图 -->
<view class="swiper">
<u-swiper :list="list" height="340" border-radius="0"></u-swiper>
</view>
</view> </view>
</template> </template>
@ -8,11 +17,44 @@
export default { export default {
data() { data() {
return { return {
title: 'Hello' list: [
// {
// image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
// title: '西'
// },
// {
// image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
// title: ''
// },
// {
// image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
// title: '西'
// }
]
} }
}, },
//
onLoad() { onLoad() {
uni.request({
url:'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
})
// .then(console.log)
//promise
.then(res=>{
const message = res[1].data.message
// 1
/*
message.forEach(v => {
v.image = v.image_src
})
this.list = [...message]
*/
//2
this.list = message.map(v=>({
...v,image:v.image_src
}))
//({}), , ,(), return
})
}, },
methods: { methods: {
@ -21,5 +63,16 @@
</script> </script>
<style lang="scss"> <style lang="scss">
.search {
/*
设计稿375px
375px = 750rpx
5px = 10rpx
*/
padding: 10rpx;
background-color: #eb4450;
/*
轮播图750px宽, 340px高
*/
}
</style> </style>