第二步,将变量绑定到view中,如:<view style="color:{{color}}">
第斗弯三步,在view中添加事件,如: bindtap="changeColor"
第四步,在薯告相应js文件中添加该自定义方法:
, changeColor: function(e){
this.setData({ color : '#fff' })
}
1、背景图片设置可以用服务器上的图片。
2、也可以将本地图片转成base64的。
wxml:
<view class="topview-left" style="background-image: url({{background}})mode='scaleToFill'"/>
js:
data: {
background: "肢山判/style/images/icon_coupon_backgroud.png",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
//设置背景图片
let base64 = wx.getFileSystemManager().readFileSync(this.data.background, 'base64')
this.setData({
'background': 'data:image/pngbase64,' + base64
})
//设置导航栏标题
wx.setNavigationBarTitle({
title: '下发优惠券'
})
},
wxss:
.topview-left {
display: flex
flex-direction: column
align-items: center
justify-content: center
width: 30%
height: 113px
background-repeat: no-repeat/** 不重复*/
background-size: 100% 100%
background-image: url('data:image/pngbase64,base64码')/** 添加背景图片的*/
}
3、也可以直接设置定位实现。
<view style="display: flexalign-items: centertext-align:centerjustify-content: centermargin-bottom:10px">
<image src="/pagesChronic/images/icon_case_background.png" style="height:26pxwidth:167pxposition:absolute"></image>
历改 <text style="position: relativecolor:#FF9721">评价</text>唯轮
</view>
效果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)