pp电子

登录
免费开通

在 mpvue 使用 echarts 小程序组件

  详细操作

  在 mpvue 使用 echarts 小程序组件 。。。。下载echarts-for-weixin 。。。。

  把其ec-canvas目录移动到 mpvue 项目的static目录下 。。。。

  对ec-canvas/ec-canvas.js举行小调解,,,, ,,思量提 pr 到 ec-canvas 。。。。

  修改 ready 为异步获取数据 。。。。

  ready: function () {

  // 异步获取

  setTimeout(() => {

  if (!this.data.ec) {

  console.warn('组件需绑定 ec 变量,,,, ,,例:');

  return;

  }

  if (!this.data.ec.lazyLoad) {

  this.init();

  }

  }, 10)

  }

  为 init 添加吸收 options 传参

  var query = wx.createSelectorQuery().in(this);

  query.select('.ec-canvas').boundingClientRect(res => {

  if (typeof callback === 'function') {

  this.chart = callback(canvas, res.width, res.height);

  }

  else if (this.data.ec && this.data.ec.onInit) {

  this.chart = this.data.ec.onInit(canvas, res.width, res.height);

  }

  else if (this.data.ec && this.data.ec.options) {

  // 添加吸收 options 传参

  const ec = this.data.ec

  function initChart(canvas, width, height) {

  const chart = echarts.init(canvas, null, {

  width: width,

  height: height

  });

  canvas.setChart(chart);

  chart.setOption(ec.options);

  return chart;

  }

  this.chart = initChart(canvas, res.width, res.height);

  }

  }).exec();

  建设pages/bar页面,,,, ,,目录如下:

  .

  └── pages

  └── bar

  ├── index.vue

  └── main.js

  在 main.js 中引入微信小程序的自界说组件

  import Vue from 'vue'

  import App from './index'

  const app = new Vue(App)

  app.$mount()

  // 添加 config json

  export default {

  config: {

  // 这儿添加要用的小程序组件

  usingComponents: {

  'ec-canvas': '../../../static/ec-canvas/ec-canvas'

  }

  }

  }

  在 app.vue 中添加 options、template 等相关设置

  Build Setup

  # install dependencies

  npm install

  # serve with hot reload at localhost:8080

  npm run dev

  # build for production with minification

  npm run build

  # build for production and view the bundle analyzer report

  npm run build --report


【本站声明】
  1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,,, ,,由于未联系到知识产权人或未发明有关知识产权的挂号,,,, ,,若有知识产权人并不肯意我们使用,,,, ,,若是有侵权请连忙联系 。。。。
  2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,,, ,,仅系客观性形貌,,,, ,,如您需要相识该类商品/服务详细的资讯,,,, ,,请您直接与该类商品/服务的提供者联系 。。。。


KESION pp电子软件

KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,, ,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案 。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等 。。。。

KESION 一直通过手艺立异,,,, ,,提供产品和服务,,,, ,,助力企业向数字化转型,,,, ,,通过科技驱动商业刷新,,,, ,,让商业变得更智慧!



▼点击进入pp电子官网相识更多



热门标签
微信小程序
上/下篇
  • 微信小程序直播订阅提醒功效组件引入

  • React转微信小程序:从React类界说到Component挪用

换一换相关推荐
精选内容
热门精选
pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站
【网站地图】
在 mpvue 使用 echarts 小程序组件 - KES