進(jìn)入微信小程序彈出廣告圖片功能

微信彈出廣告圖.png

直接上代碼

wxml

<view class="poster" wx:if='{{isSuccess}}'>
  <view class="advert">
    <view bindtap="close">×</view>
    <image
      src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1604055118571&di=b7fb3c322e2a77440b3791cad3a7b003&imgtype=0&src=http%3A%2F%2Fhomesitetask.zbjimg.com%2Fhomesite%2Ftask%2F21511972_095056617000_2.jpg%2Forigine%2F1164cc8d-daa1-405a-bd79-5b9aa3538ec5" mode="widthFix">
    </image>
  </view>
</view>

wxss

//設(shè)置大view高寬為屏幕大小,fixed定位,透明居最外層

/* pages/home/home.wxss */
.poster {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.advert {
  width: 550rpx;
  height: 750rpx;
  position: relative;
}

.advert image {
  width: 100%;
  height: 100%;
  border-radius: 10rpx;
}

.advert view {
  width: 40rpx;
  height: 40rpx;
  line-height: 40rpx;
  text-align: center;
  border-radius: 50%;
  border: 1rpx solid #fff;
  color: #fff;
  position: absolute;
  left: 50%;
  bottom: -13%;
  transform: translate(-50%, 0);
}

js

//isSuccess控制顯示隱藏
Page({
  data: {
    isSuccess: true
  },
  close() {
//點(diǎn)擊x號關(guān)閉
    this.setData({
      isSuccess: false
    })
  },
})
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容