【问题标题】:angular is not defined after adding async attribute in html [duplicate]在html中添加异步属性后未定义角度[重复]
【发布时间】:2020-09-30 22:55:52
【问题描述】:

我正在尝试提高我的网页在 chrome Audit 中的性能。我在我的脚本标签中添加了“异步”,如下所示,

<body ng-cloak id="body">
   <script
    src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,places&sensor=false&key=AIzaSyBMxfoPEGblWmG-R6eLz6Oe0FS6wPEnMNA"
    async></script><!-- bower:js -->
   <script src="vendor/app.deps.js" async></script><!-- endinject -->
   <script>angular.module('templates', []);</script><!-- inject:js -->
   <script src="js/app-1591858972321.js" async></script>
   <script src="js/partials.min.js" async></script><!-- endinject -->

</body>

加载时出现以下错误,

angular is not defined in 'js/app-1591858972321.js'
angular is not defined in 'js/partials.min.js'

谁能建议我解决这些错误。谢谢。

【问题讨论】:

    标签: javascript html angularjs seo audit


    【解决方案1】:

    角度脚本必须按定义的顺序加载。供应商需要在您的脚本之前加载。异步破坏订单。尝试使用 defer instand of async Any way to control Javascript Async Load Order?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-05
      • 1970-01-01
      • 2020-10-22
      • 2018-11-18
      • 2016-05-18
      • 1970-01-01
      • 2018-03-04
      • 1970-01-01
      相关资源
      最近更新 更多