实训DAY04
page 順序調(diào)換 第一個(gè)地址為默認(rèn)打開的首頁(yè)
換其他頁(yè)面頂行條格式 在json里面 可將app.json的搬過(guò)來(lái)
不需要授權(quán)則獲取頭像等信息的方法:
open-data標(biāo)簽
<open-data type='userAvatarUrl'></open-data> 用戶頭像
<open-data type='userNickName' id='uN'></open-data> 用戶名稱
給頭像加個(gè)view標(biāo)簽可進(jìn)行樣式更改 變成圓形需要 border-radius:50%; overflow: hidden;
imagePath:0
獲取本地圖片路徑:
wx.chooseImage({
? ? ? success: function (res) {
? ? ? ? _this.data.imagePath = res.tempFilePaths[0];
? ? ? }
? ? })
點(diǎn)擊按鈕,通過(guò)圖片路徑獲取圖片的banse64格式:
<button bindtap='tp'>獲取背景圖</button>
tp:function(){
? ? var _this = this;
? ? var f = wx.getFileSystemManager();
? ? console.log(_this.data.imagePath);
? ? f.readFile({
? ? ? filePath: _this.data.imagePath,
? ? ? encoding:'base64',
? ? ? success:function(e){
? ? ? ? console.log(e.data)
? ? ? }
? ? }) ??
? }
背景圖不支持本地路徑:
background-image:url(data:image/PNG;base64,XXXX)
?
總結(jié)