小程序swiper里用canvas樣式錯(cuò)亂,電腦正常的,放手機(jī)上就出錯(cuò)了
wxml
<!-- pages/index/test.wxml -->
<view>
<scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}">
<view class="tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="swichNav">
健康
</view>
<view class="tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="swichNav">
情感
</view>
<view class="tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="swichNav">
職場(chǎng)
</view>
<view class="tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="swichNav">
育兒
</view>
<view class="tab-item {{currentTab==4?'active':''}}" data-current="4" bindtap="swichNav">
糾紛
</view>
<view class="tab-item {{currentTab==5?'active':''}}" data-current="5" bindtap="swichNav">
青蔥
</view>
<view class="tab-item {{currentTab==6?'active':''}}" data-current="6" bindtap="swichNav">
全部
</view>
<view class="tab-item {{currentTab==7?'active':''}}" data-current="7" bindtap="swichNav">
其他
</view>
</scroll-view>
<swiper class="tab-content" current="{{currentTab}}" duration="300" bindchange="switchTab" style="height:{{winHeight}}rpx">
<swiper-item wx:for="{{[0,1,2,3,4,5,6,7]}}" wx:key="*this">
<!-- <scroll-view scroll-y="true" class="scoll-h" >
<block wx:for="{{[1,2,3,4,5,6,7,8]}}" wx:key="*this">
<view class="item-ans">
<view class="avatar">
<image class="img" src="http://ookzqad11.bkt.clouddn.com/avatar.png"></image>
</view>
<view class="expertInfo">
<view class="name">歡顏</view>
<view class="tag">知名情感博主</view>
<view class="answerHistory">134個(gè)回答,2234人聽過 </view>
</view>
<navigator url="/pages/askExpert/expertDetail" class="askBtn">問TA</navigator>
</view>
</block>
</scroll-view> -->
<view class="wrap">
<view class="top">
<canvas class="cir" style="width:212px; height:212px;" canvas-id="canvasArc-{{item}}"></canvas>
<view class="cc">中間</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
js
var app = getApp();
Page({
data: {
winHeight: "",//窗口高度
currentTab: 0, //預(yù)設(shè)當(dāng)前項(xiàng)的值
scrollLeft: 0, //tab標(biāo)題的滾動(dòng)條位置
expertList: [{ //假數(shù)據(jù)
img: "avatar.png",
name: "歡顔",
tag: "知名情感博主",
answer: 134,
listen: 2234
}]
},
// 滾動(dòng)切換標(biāo)簽樣式
switchTab: function (e) {
this.setData({
currentTab: e.detail.current
});
this.checkCor();
function createCanvas(id) {
// 頁面渲染完成
var cxt_arc = wx.createCanvasContext('canvasArc-'+id);//創(chuàng)建并返回繪圖上下文context對(duì)象。
cxt_arc.setLineWidth(6);
cxt_arc.setStrokeStyle('#d2d2d2');
cxt_arc.setLineCap('round')
cxt_arc.beginPath();//開始一個(gè)新的路徑
cxt_arc.arc(106, 106, 100, 0, 2 * Math.PI, false);//設(shè)置一個(gè)原點(diǎn)(106,106),半徑為100的圓的路徑到當(dāng)前路徑
cxt_arc.stroke();//對(duì)當(dāng)前路徑進(jìn)行描邊
cxt_arc.setLineWidth(6);
cxt_arc.setStrokeStyle('#3ea6ff');
cxt_arc.setLineCap('round')
cxt_arc.beginPath();//開始一個(gè)新的路徑
cxt_arc.arc(106, 106, 100, -Math.PI * 1 / 2, Math.PI * 6 / 5, false);
cxt_arc.stroke();//對(duì)當(dāng)前路徑進(jìn)行描邊
cxt_arc.draw();
}
setTimeout(() => {
createCanvas(e.detail.current)
}, 2000);
},
// 點(diǎn)擊標(biāo)題切換當(dāng)前頁時(shí)改變樣式
swichNav: function (e) {
var cur = e.target.dataset.current;
if (this.data.currentTaB == cur) { return false; }
else {
this.setData({
currentTab: cur
})
}
},
//判斷當(dāng)前滾動(dòng)超過一屏?xí)r,設(shè)置tab標(biāo)題滾動(dòng)條。
checkCor: function () {
if (this.data.currentTab > 4) {
this.setData({
scrollLeft: 300
})
} else {
this.setData({
scrollLeft: 0
})
}
},
onLoad: function () {
var that = this;
// 高度自適應(yīng)
wx.getSystemInfo({
success: function (res) {
var clientHeight = res.windowHeight,
clientWidth = res.windowWidth,
rpxR = 750 / clientWidth;
var calc = clientHeight * rpxR - 180;
console.log(calc)
that.setData({
winHeight: calc
});
}
});
},
onReady: function () {
[0,1,2,3,4,5,6,7].forEach(el => {
// createCanvas(el);
});
function createCanvas(id) {
// 頁面渲染完成
var cxt_arc = wx.createCanvasContext('canvasArc-'+id);//創(chuàng)建并返回繪圖上下文context對(duì)象。
cxt_arc.setLineWidth(6);
cxt_arc.setStrokeStyle('#d2d2d2');
cxt_arc.setLineCap('round')
cxt_arc.beginPath();//開始一個(gè)新的路徑
cxt_arc.arc(106, 106, 100, 0, 2 * Math.PI, false);//設(shè)置一個(gè)原點(diǎn)(106,106),半徑為100的圓的路徑到當(dāng)前路徑
cxt_arc.stroke();//對(duì)當(dāng)前路徑進(jìn)行描邊
cxt_arc.setLineWidth(6);
cxt_arc.setStrokeStyle('#3ea6ff');
cxt_arc.setLineCap('round')
cxt_arc.beginPath();//開始一個(gè)新的路徑
cxt_arc.arc(106, 106, 100, -Math.PI * 1 / 2, Math.PI * 6 / 5, false);
cxt_arc.stroke();//對(duì)當(dāng)前路徑進(jìn)行描邊
cxt_arc.draw();
}
},
footerTap: app.footerTap
})
wxss
/* pages/index/test.wxss */
.tab-h{
height: 80rpx;width: 100%; box-sizing: border-box;overflow: hidden;line-height: 80rpx;background: #F7F7F7; font-size: 16px; white-space: nowrap;position: fixed;top: 0; left: 0; z-index: 99;}
.tab-item{margin:0 36rpx;display: inline-block;}
.tab-item.active{color: #4675F9;position: relative;}
.tab-item.active:after{ content: "";display: block;height: 8rpx;width: 52rpx;background: #4675F9;position: absolute; bottom: 0;left: 5rpx;border-radius: 16rpx;}
.item-ans{ width: 100%;display: flex; flex-grow: row no-wrap;justify-content: space-between; padding: 30rpx;box-sizing: border-box; height: 180rpx;align-items: center;border-bottom: 1px solid #F2F2F2;}
.avatar{width: 100rpx;height: 100rpx;position: relative;padding-right: 30rpx;}
.avatar .img{width: 100%;height: 100%;}
.avatar .doyen{width: 40rpx;height: 40rpx;position: absolute;bottom: -2px;right: 20rpx;}
.expertInfo{font-size: 12px;flex-grow: 2;color: #B0B0B0;line-height: 1.5em;}
.expertInfo .name{font-size: 16px;color:#000;margin-bottom: 6px;}
.askBtn{ width: 120rpx;height: 60rpx;line-height: 60rpx;text-align: center;font-size: 14px; border-radius: 60rpx;border: 1px solid #4675F9; color:#4675F9;}
.tab-content{margin-top: 80rpx;}
.scoll-h{height: 100%;}
.cir{
display: inline-block;
margin-top: 20rpx;
}
.top{
text-align: center
}
.cc{
margin-top: -120px;
}
求幫幫忙 運(yùn)行看看怎么解決~
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。