1、问题描述

  在使用Spring Cloud 整合Hystrix Dashboard组件监控Hystrix时控制台出现jQuery报错Uncaught: TypeError: e.indexOf is not a function,并且监控界面一直loading。

Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_jar


SpringBoot版本:2.2.5.RELEASE

SpringCloud版本:Hoxton.SR6

2、解决方案

新版本中springcloud将jQuery版本升级为3.4.1,定位到monitor.ftlh文件中,js的写法如下:

$(window).load(function()

但是在jQuery3.4.1已经废弃上面写法,所以我们需要将monitor.ftlh文件中的所有上述调用方式改为如下代码:

$(window).on("load",function()

之后编译jar源文件,重新打包引入。

2.1 在本地的maven仓库中找到Dashboard依赖的jar包

注意修改的是spring-cloud-netflix-hystrix-dashboard不是spring-cloud-starter-netflix-hystrix-dashboard

Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_jar_02


找到文件monitor.ftlh,可以先将这个文件先解压到别处 ,最后在替换下

Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_spring_03


修改2处Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_dashboard_04(window).on(“load”,function(),我下面截图中的是我修改之后的

Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_dashboard_05


最后发现界面正常

Hystrix Dashboard界面中jQuery报错Uncaught: TypeError: e.indexOf is not a function_jQuery_06