版本:easyadmin 2
原引用方式为 预加载js中
define(["jquery", "easy-admin", "echarts", "echarts-theme", "miniAdmin", "miniTab","china"], function ($, ea, echarts, undefined, miniAdmin, miniTab,china) {
但是可能我服务器比较垃圾吧,加载非常慢
于是尝试在html页面直接加载echarts
烦恼来了
各种坑:各种错误 未定义等
后经分析可能是因为框架引用的require.js异步加载的原因,最终解决方案是在模板页require引入之前直接增加js引入
原代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{$title|default='EasyAdmin后台管理'}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="__STATIC__/admin/css/public.css?v={$version}" media="all">
<link rel="stylesheet" href="__STATIC__/admin/css/public.css?v={$version}" media="all">
<script src="https://code.highcharts.com.cn/highcharts/highcharts.js"></script>
<script>
window.CONFIG = {
ADMIN: "{$adminModuleName|default='admin'}",
CONTROLLER_JS_PATH: "{$thisControllerJsPath|default=''}",
ACTION: "{$thisAction|default=''}",
AUTOLOAD_JS: "{$autoloadJs|default='false'}",
IS_SUPER_ADMIN: "{$isSuperAdmin|default='false'}",
VERSION: "{$version|default='1.0.0'}",
};
</script>
<script src="__STATIC__/plugs/layui-v2.5.5/layui.all.js?v={$version}" charset="utf-8"></script>
<script src="__STATIC__/plugs/require-2.3.6/require.js?v={$version}" charset="utf-8"></script>
<script src="__STATIC__/config-admin.js?v={$version}" charset="utf-8"></script>
</head>
<body>
{__CONTENT__}
</body>
</html>
修改后
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{$title|default='后台管理'}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="__STATIC__/admin/css/public.css?v={$version}" media="all">
<script>
window.CONFIG = {
ADMIN: "{$adminModuleName|default='admin'}",
CONTROLLER_JS_PATH: "{$thisControllerJsPath|default=''}",
ACTION: "{$thisAction|default=''}",
AUTOLOAD_JS: "{$autoloadJs|default='false'}",
IS_SUPER_ADMIN: "{$isSuperAdmin|default='false'}",
VERSION: "{$version|default='1.0.0'}",
};
</script>
<script src="__STATIC__/plugs/layui-v2.5.5/layui.all.js?v={$version}" charset="utf-8"></script>
<script src="__STATIC__/plugs/echarts/echarts.min.js" charset="utf-8"></script>
<script src="__STATIC__/plugs/require-2.3.6/require.js?v={$version}"></script>
<script src="__STATIC__/config-admin.js?v={$version}" charset="utf-8"></script>
</head>
<body>
{__CONTENT__}
</body>
</html>
问题解决。