[英]Ons navigation (onsen UI), use of javascript code
When I use the standard technique ons-navigation, the javascript code on the ons-page does not execute. 当我使用标准技术ons导航时,不会执行ons页面上的javascript代码。 Does anyone know what I do wrong?
有人知道我做错了吗?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user- scalable=no">
<script src="components/loader.js"></script>
<link rel="stylesheet" href="components/loader.css">
<link rel="stylesheet" href="css/style.css">
<script>
ons.bootstrap();
ons.disableAutoStatusBarFill(); // (Monaca enables StatusBar plugin by default)
</script>
</head>
<body>
<ons-navigator var="myNavigator" page="login.html">
</ons-navigator>
</body>
</html>
And here is the login.html:
<ons-page>
<script>
console.log("test11");
</script>
</ons-page>
The reason why it's not working is that the browser won't execute script tags that are added through replacing el.innerHTML
, which is what Onsen does when you push a page. 它不起作用的原因是浏览器无法执行通过替换
el.innerHTML
而添加的脚本标记,这是Onsen在推页面时所做的。
Please see this question for why it's not working: Can scripts be inserted with innerHTML? 请查看此问题以了解其为何不起作用: 脚本可以与innerHTML一起插入吗?
You shouldn't use inline script tags mixed in your HTML. 您不应该在HTML中使用内联脚本标签。 Please look up how to structure you're JavaScript.
请查看如何构建JavaScript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.