简体   繁体   English

移动Chrome应用和JS引用的处理

[英]Mobile Chrome Apps and handling of JS refs

New at Chrome Apps. Chrome Apps的新功能。 Using cca and CADT for mobile development. 使用cca和CADT进行移动开发。

In the following code, why is jQuery not immediately available? 在以下代码中,为什么jQuery无法立即使用? Is there some async magic being auto-applied? 是否有一些异步魔术被自动应用?

I don't have this behavior in a vanilla cordova project. 我在香草科尔多瓦项目中没有这种行为。

<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">

    setTimeout(function()
    {
        console.log($);    // $ is jQuery
    }, 1000);

    console.log($);        // $ is undefined

</script>

Our current bootstrap code will not load the html of your chrome app windows in a way you typically expect from a browser. 我们当前的引导程序代码不会以您通常希望浏览器加载的方式加载chrome应用程序窗口的html。 The reasons are long, but the short story is that we have to bootstrap to set up the environment, then inject the content around the bootstrap. 原因很长,但总的来说是,我们必须引导程序来设置环境,然后将内容注入引导程序中。

One of the consequences is that scripts do not block dom content loading. 结果之一是脚本不会阻止dom内容加载。 I guess another consequence is that inline script execution is not delayed until preceding scripts have loaded. 我想另一个结果是,内联脚本的执行不会延迟,直到之前的脚本已加载。

We may be able to fix this bug, I'll take a look. 我们也许可以修复该错误,我来看一下。 I've filed: https://github.com/MobileChromeApps/mobile-chrome-apps/issues/482 我已提交: https : //github.com/MobileChromeApps/mobile-chrome-apps/issues/482

Thanks for reporting the issue! 感谢您报告问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM