QT加载本地的一个html文件,发现js未被载入
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
hello world!
</body>
<script type="text/javascript">
$().ready(function(){
alert("Ready!");//在浏览器上可以输出,在QT上未输出
})
</script>
</html>
m_webView = new QWebEngineView(this);
QString htmlPath = QCoreApplication::applicationDirPath() + "/";
QString htmlFile = htmlPath + "TEST.html";
m_webView->page()->load(QUrl("file:///" + htmlFile));
m_webView->resize(800,600);
测试效果:QT上显示出来了Hello World!,但是Alert没有弹出来!有一条提示 js: Uncaught ReferenceError: $ is not defined
而直接将这个html文件拖在浏览器上,就可以弹出Alert
//QT6.4 MSVC2019