当前位置: 首页 > news >正文

echarts在uniapp中使用安卓真机运行时无法显示的问题

文章目录

  • 一、实现效果
  • 二、话不多说,上源码

  • 前言:我们在uniapp中开发的时候,开发的时候很正常,echarts的图形在h5页面上也是很正常的,但是当我们打包成安卓app或者使用安卓真机运行的时候,图形根本就没有渲染出来。以下是我的解决方法,摸索了两天,终于在我不懈的努力下搞定了

一、实现效果

在这里插入图片描述

二、话不多说,上源码

1、echarts代码必须写在 lang="renderjs"的script 中,调用的时候必须在:change中调用<script module="renderScript" lang="renderjs">

<template><view class="content"><view class="taskModel"><view class="chat" id="chat1" :msg="msg1" :change:msg="renderScript.initChart"></view><view class="chatText">填报</view></view><view class="taskModel"><view class="chat" id="chat2" :msg="msg2" :change:msg="renderScript.initChart"></view><view class="chatText">审批</view></view><view class="taskModel"><view class="chat" id="chat3" :msg="msg3" :change:msg="renderScript.initChart"></view><view class="chatText">通知</view></view></view>
</template>
<script>
export default {components:{Calendar},data() {this.chat1 = nullreturn {msg1: 1,msg2: 1,msg3: 1};},created() {// 调用方法 this.getUnSuccTask()},methods: {// 未完成任务getUnSuccTask(){// 这里是请求方法this.$store.dispatch('actioncore/cpcGetApi', {url: '/user/PhoneDJTodoCount',param: null}).then(res => {if(res.data  != null){var approval = (res.data.approval != null && res.data.approval !== '') ? res.data.approval: 0;var meeting = (res.data.meeting != null && res.data.meeting !== '') ? res.data.meeting: 0;var todos = (res.data.todos != null && res.data.todos !== '') ? res.data.todos: 0;var total = approval+meeting+todosvar msg1 = { // 填报total: total == 0 ? 100 : total,val: todos,}var msg2 = { // 审批total: total == 0 ? 100 : total ,val: approval,}var msg3 = { // 通知total: total == 0 ? 100 : total,val: meeting,}this.msg1 = msg1this.msg2 = msg2this.msg3 = msg3}}).catch(() => {})}},
};
</script>
<script module="renderScript" lang="renderjs">
import {getIndexYH} from '@/utils/chartOptions.js'
import * as echarts from 'echarts'export default {methods: {// 这里也可以在renderjs中mounted中调用,但是只是初始化initChart(newValue, oldValue, ownerVm, vm) {if (newValue == 1) {return;}var option = {title: [{text: '{a|'+cuVal+'}',show: true,x: 'center',y: 'center',textStyle: {rich: {a: {fontSize: 14,color: '#5A75E1',padding: [0, 0,0, 0],fontWeight: 'bold' }},},},],polar: {center: ['50%', '50%'],radius: ['75%', '100%'],},angleAxis: {max: maxVal,show: false,},radiusAxis: {type: 'category',show: true,axisLabel: {show: false,},axisLine: {show: false,},axisTick: {show: false,},},series: [{name: '',type: 'bar',roundCap: true,showBackground: true,backgroundStyle: {color: '#FFF',},data: [cuVal],coordinateSystem: 'polar',itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{offset: 0,color: '#5A76FF',},{offset: 1,color: '#AEC7FA',},]),},},},{name: '',type: 'gauge',radius: '54%',axisLine: {lineStyle: {color: [],width: 1,},},axisLabel: {show: false,},axisTick: {show: false,},splitLine: {show: false,}}],};var chart = echarts.init(document.getElementById(vm.$el.id))chart.setOption(option)}},};
</script>
http://www.xdnf.cn/news/888769.html

相关文章:

  • C及C++编译链接过程详解
  • c++ Base58编码解码
  • 【华为云Astro-服务编排】服务编排中图元的使用与配置
  • 【Android基础回顾】四:ServiceManager
  • gc2053驱动学习笔记
  • CppCon 2015 学习:Concurrency TS Editor’s Report
  • nvidia系列教程-Usb otg模式修改为host模式
  • 从理论崩塌到新路径:捷克科学院APL Photonics论文重构涡旋光技术边界
  • 设计模式-2 结构型模式
  • 轻触开关是什么?
  • Web前端之隐藏元素方式的区别、Vue循环标签的时候在同一标签上隐藏元素的解决办法、hidden、display、visibility
  • 国产录播一体机:科技赋能智慧教育信息化
  • el-draw的文件列表和清单内容布局实现
  • 兰亭妙微 | 医疗软件的界面设计能有多专业?
  • 软件测试全攻略:Postman工具的使用
  • 将 WTL 向导集成到 Visual Studio 2022 的完整教程
  • HBuilder 发行Android(apk包)全流程指南
  • MySQL 的锁机制【深度全面】
  • windows命令行面板升级Git版本
  • 4G 模块工作原理及应用场景
  • 【AI News | 20250605】每日AI进展
  • 使用Node.js分片上传大文件到阿里云OSS
  • Gemini开源项目DeepResearch:基于LangGraph的智能研究代理技术原理与实现
  • freeRTOS 消息队列之一个事件添加到消息队列超时怎么处理
  • 【threejs】每天一个小案例讲解
  • Dubbo Logback 远程调用携带traceid
  • 【Algorithm】Segment Tree 简单介绍
  • C#异步编程:从线程到Task的进化之路
  • Linux 内核队列调度相关内核选项详解
  • Java + Spring Boot + Mybatis 插入数据后,获取自增 id 的方法