【微信小程序】调用api

£神魔★判官ぃ 2022-11-05 08:36 356阅读 0赞

index.js

  1. onLoad: function (options) {
  2. wx.request({
  3. url: 'https://movie.querydata.org/api?id=34841067',
  4. success:(result)=>{
  5. this.setData({
  6. swiperList:result.data.data
  7. })
  8. }
  9. })
  10. },

index.wxml

  1. <view class="index_swiper">
  2. <swiper autoplay indicator-dots circular>
  3. <swiper-item
  4. wx:for="{
  5. {swiperList}}"
  6. >
  7. <navigator url="{
  8. {item.navigator_url}}">
  9. <image mode="widthFix" src="{
  10. {item.poster}}"></image>
  11. </navigator>
  12. </swiper-item>
  13. </swiper>
  14. </view>

index.less 设置好之后自动转成 .wxss
index.less

  1. .index_swiper{
  2. swiper{
  3. height: 760rpx;
  4. //width: 531rpx;
  5. image{
  6. width: 100%;
  7. }
  8. }
  9. }

或者直接在index.wxss写

  1. .index_swiper swiper {
  2. height: 760rpx;
  3. }
  4. .index_swiper swiper image {
  5. width: 100%;
  6. }

发表评论

表情:
评论列表 (有 0 条评论,356人围观)

还没有评论,来说两句吧...

相关阅读