Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ve-map 不显示,其他组件的都正常 #404

Closed
Toxicant2 opened this issue Jun 27, 2018 · 13 comments
Closed

ve-map 不显示,其他组件的都正常 #404

Toxicant2 opened this issue Jun 27, 2018 · 13 comments

Comments

@Toxicant2
Copy link

Summary 简述

echarts @^4.1.0
v-charts @^1.17.6
其他的折现,柱状都显示正常,只有地图完全不加载,其他项目里又是正常的,完全想不到会受什么影响了,地图组件只显示个div,里面没有加载canvas

Reproduce 重现示例

image
image

@xiguaxigua
Copy link
Contributor

把 el-row 换成 div 试试。

@Toxicant2
Copy link
Author

还是一样的,而且el-row里面的ve-line是可以正常显示的

@xiguaxigua
Copy link
Contributor

https://jsfiddle.net/vue_echarts/k8wf54oe/4/

看看上面的例子在你的浏览器上是否有问题。

@xiguaxigua
Copy link
Contributor

page-main 和 page-container 的样式分别是什么?

@Toxicant2
Copy link
Author

浏览器是chrome最新,例子没有任何问题,我现在里面只有div,还是ve-map不正常显示
image

@xiguaxigua
Copy link
Contributor

map 组件在项目中是如何引入的 ?

@xiguaxigua
Copy link
Contributor

参考示例项目,看看能不能重现出你现在遇到的问题 https://codesandbox.io/s/z69myovqzx

@Toxicant2
Copy link
Author

image

image

@Toxicant2
Copy link
Author

只在我的项目里有这个问题,示例没重现

@xiguaxigua
Copy link
Contributor

确实是个奇怪的问题,不过我这边没有办法重现,所以也不好确定究竟是什么原因导致的。您的项目代码方便我看一下吗,如果不方便的话,可以把比较关键的相关几个页面的代码提供一下,只要能够在我的本地重现就好办了。

@Toxicant2
Copy link
Author

Toxicant2 commented Jun 27, 2018

您好,项目上传了,直接npm install,run就可以了,
页面在统计下的第一个菜单,
代码在src/views/report/disease-ctrl-chart.vue
easy-project.zip

@xiguaxigua
Copy link
Contributor

ve-map 获取地图数据的时候使用了一个简单的 ajax 请求,然而项目中的 mockjs 把 xhr 封装了一层,应该触发的 onload 没有触发出来,所以这个 promise 一直在 pending 状态,组件的渲染流程没有继续下去,所以就没有正常显示出来。
有两种方案可以解决这个问题:

  1. 去掉 mockjs ,使用别的方法来处理测试数据。
  2. 使用 mapOrigin 属性,预先在项目中引入地图 json 并通过 mapOrigin 传递给组件,这样就不需要通过 ajax 的方式引入地图了。
import China from 'echarts/map/json/china.json'

this.chartSettings = {
  mapOrigin: China
}

@Toxicant2
Copy link
Author

嗯,问题解决了。太感谢了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants