引用ECharts不显示,但是新建了一个项目把页面复制过去能显示,这是为毛

一只LadyBug 2018-04-13 04:52:11
import * as echarts from '../../ec-canvas/echarts.js';

const app = getApp();

function initChart(canvas, width, height) {
const chart = echarts.init(canvas, null, {
width: width,
height: height
});
canvas.setChart(chart);


var option = {
backgroundColor: "#fff",
color: ["#37A2DA", "#67E0E3", "#9FE6B8"],

tooltip: {
trigger: 'axis'
},
legend: {

data: ['A商品', 'B商品', 'C商品']
},
grid: {
containLabel: true
},

xAxis: {
type: 'category',
boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
x: 'center',
type: 'value'
},
series: [{
name: 'A商品',
type: 'line',
smooth: true,
data: [18, 36, 65, 30, 78, 40, 33]
}, {
name: 'B商品',
type: 'line',
smooth: true,
data: [12, 50, 51, 35, 70, 30, 20]
}, {
name: 'C商品',
type: 'line',
smooth: true,
data: [10, 30, 31, 50, 40, 20, 10]
}]
};

chart.setOption(option);
return chart;
}

Page({
onShareAppMessage: function (res) {
return {
title: 'ECharts 可以在微信小程序中使用啦!',
path: '/pages/index/index',
success: function () { },
fail: function () { }
}
},
data: {
ec: {
onInit: initChart
}
},

onReady() {
}
});

没有报错之类的
...全文
1622 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
前端学习fam 2019-08-16
  • 打赏
  • 举报
回复
引用 5 楼 我视而不见 的回复:
问题出在app.wxss

你修改成他一样的,就能显示出来了,我碰到你和你同样的问题

/**app.wxss**/
.container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;

display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
可以啊
我视而不见 2018-07-26
  • 打赏
  • 举报
回复
问题出在app.wxss

你修改成他一样的,就能显示出来了,我碰到你和你同样的问题

/**app.wxss**/
.container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;

display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
一只LadyBug 2018-04-16
  • 打赏
  • 举报
回复
有没有路过的大佬能解答一下啊啊啊啊
一只LadyBug 2018-04-13
  • 打赏
  • 举报
回复
json { "usingComponents": { "ec-canvas": "../../ec-canvas/ec-canvas" } } wxml <view class="container"> <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas> </view>

3,159

社区成员

发帖
与我相关
我的任务
社区描述
微信开发即微信公众平台开发,将企业信息、服务、活动等内容通过微信网页的方式进行表现,通过二次开发可以将公众账号由一个媒体型营销工具转化成提供服务的产品。
社区管理员
  • 微信开发
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧