Javascript cordova中的文本字段显示错误
我尝试在cordova中构建应用程序时,应用程序的显示出现问题。代码如下:Javascript cordova中的文本字段显示错误,javascript,android,css,cordova,meta,Javascript,Android,Css,Cordova,Meta,我尝试在cordova中构建应用程序时,应用程序的显示出现问题。代码如下: <html> <head> <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<title>Swaggity swag swag</title>
</head>
<body>
<form action="res/link2.html">
<input type="text" placeholder="Name" name="name">
<input type="text" placeholder="Text" name="comment">
<button type="submit">Leggo!</button>
</form>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
Swaggity swag swag
莱戈!
当我构建它时,显示的文本字段最终显示如下:
我希望你能帮我解决这个问题,谢谢 我将您的代码放在一个新的cordova应用程序(CLI版本5.1.1;Visual Studio 2015)中,在输出控制台中出现了一些安全错误,因为您正在引用。不管怎么说,你提供的截图看起来像是某种加载的样式,但给出了奇怪的结果。 在我的例子中,我在Visual Studio中的JavaScript控制台中遇到以下错误:
Refused to load the stylesheet 'http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline'".
index.html (15,0)
Refused to load the script 'http://code.jquery.com/jquery-1.11.1.min.js' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
index.html (0,0)
Refused to load the script 'http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
index.html (0,0)
为了避免这些错误,我更改了内容安全策略的meta标记,并添加了:
通过这些更改,ripple中的所有内容看起来都很好:
由于安全策略的原因,上述解决方案无法直接在iOS、Windows 8.1/10和Android平台上运行
我认为有两种解决方案:
这将在此文件中生成一个XML条目:
<!-- Allow images, xhrs, etc. to http://code.jquery.com -->
<access origin="http://code.jquery.com" />
希望有帮助 我的回答对你有帮助吗?请投票或/并标记为答案。:)
<!-- Allow images, xhrs, etc. to http://code.jquery.com -->
<access origin="http://code.jquery.com" />