您当前的位置: 首页 > 解决方案

微信小程序的wx-charts插件-tab选项卡

  • 作者: admin
  • 发布于 2018-12-28 10:24:57
  • 来源:  
  • 栏目:解决方案

导语: 微信小程序的wx-charts插件-tab选项卡效果://index.jsvar wxCharts = require('../../utils/wxcharts-min.js');const app = getApp();var ringChart = null;Page({ data:

 

微信小程序的wx-charts插件-tab选项卡

效果:

03.gif

//index.js
var wxCharts = require('../../utils/wxcharts-min.js');
const app = getApp();
var ringChart = null;
Page({
  data: {
    selected: true,
    selected1: false
  },
  torecord() {
    wx.navigateBack({
      delta: 1,
    })
  },
  onLoad: function (e) {
    //  高度自适应
    var windowWidth = '', windowHeight = '';    //定义宽高
    try {
      var res = wx.getSystemInfoSync();    //试图获取屏幕宽高数据
      windowWidth = res.windowWidth / 750 * 690;   //以设计图750为主进行比例算换
      windowHeight = res.windowWidth / 750 * 550    //以设计图750为主进行比例算换
    } catch (e) {
      console.error('getSystemInfoSync failed!');   //如果获取失败
    }
    ringChart = new wxCharts({
      canvasId: "ringCanvas",
      type: "ring",
      series: [
        { data: 20, },
        { data: 30, },
        { data: 60, }
      ],
      width: windowWidth,
      height: windowHeight,
      dataLabel: false,
      legend: false,
    });
  },

  selected: function (e) {
    this.setData({
      selected1: false,
      selected: true
    })
  },

  selected1: function (e) {
    this.setData({
      selected: false,
      selected1: true
    })
  }
})
<view class="head">   <view class="head_item {{selected?'head_itemActive':''}}" bindtap="selected">个人</view>   <view class="ring"></view>   <view class="head_item {{selected1?'head_itemActive':''}}" bindtap='selected1'>设置</view> </view> <view class="main {{selected?'show':'hidden'}}">   <canvas canvas-id="ringCanvas" disable-scroll="true" class="canvas"></canvas>   <cover-view class='text'></cover-view> </view> <view class="main {{selected1?'show':'hidden'}}">   <text>for sutdnet month attend</text> </view>
page {
  background-color: rgba(239, 239, 240, 1);
}

.text {
  position: absolute;
  top: 380rpx;
  left: 356rpx;
}

.canvas {
  width: 100%;
  height: 550rpx;
  margin: 30rpx;
}

.head_item {
  width: 374rpx;
  text-align: center;
  font-size: 34rpx;
  color: #999;
  letter-spacing: 0;
}

.head_itemActive {
  color: rgba(87, 213, 200, 1);
}

.ring {
  width: 2rpx;
  height: 100%;
  background-color: rgba(204, 204, 204, 1);
}

.head {
  width: 100%;
  height: 100rpx;
  background-color: rgba(255, 255, 255, 1);
  border-bottom: 1rpx solid rgba(204, 204, 204, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  z-index: 10;
}

.main {
  position: absolute;
  width: 100%;
  height: 100%;
  display: block;
  box-sizing: border-box;
  padding-top: 100rpx;
  top: 0;
}

.show {
  display: block;
  text-align: center;
}

.hidden {
  display: none;
  text-align: center;
}

往后余生,唯独有你

简书作者:达叔小生

90后帅气小伙,良好的开发习惯;独立思考的能力;主动并且善于沟通

简书博客: https://www.jianshu.com/u/c785ece603d1

结语

  • 下面我将继续对 其他知识 深入讲解 ,有兴趣可以继续关注
  • 小礼物走一走 or 点赞



温馨提示:这篇文章没有解决您的问题?欢迎添加微信:18948083295,有微信小程序专业人员,保证有问必答。转载本站文章请注明转自http://www.okeydown.com/(微信小程序网)。

  • 微信扫描二维码关注官方微信
  • ▲长按图片识别二维码
关注我们

微信小程序官方微信

栏目最新
栏目推荐
返回顶部