Ionic 2:ReferenceError:webpackJsonp没有定义
我是新来的离子。 我已经开始使用超级模板的项目。 但是当我尝试在浏览器中运行应用程序。 它抛出一个错误说:
ReferenceError: webpackJsonp is not defined at http://localhost:8100/build/main.js:1:1
我已经尝试在index.html中放置vendor.js,但没有奏效。
这是index.html文件。 我已经删除了vendor.js,因为它不起作用。
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Ionic App</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico"> <link rel="manifest" href="manifest.json"> <meta name="theme-color" content="#4e8ef7"> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script> <!-- un-comment this code to enable service worker <script> if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js') .then(() => console.log('service worker installed')) .catch(err => console.log('Error', err)); } </script>--> <link href="build/main.css" rel="stylesheet"> </head> <body> <!-- Ionic's root component and where the app will load --> <ion-app></ion-app> <!-- The polyfills js is generated during the build process --> <script src="build/polyfills.js"></script> <!-- The bundle js is generated during the build process --> <script src="build/main.js"></script> </body> </html>
从字面上看,就像你一样经历了同样的事情。 我在/src/index.html中的main.js之前添加了vendor.js脚本 – 现在它在本地运行。
<!-- The polyfills js is generated during the build process --> <script src="build/polyfills.js"></script> <script src="build/vendor.js"></script> <!-- The bundle js is generated during the build process --> <script src="build/main.js"></script>
这是离子应用程序脚本的突破性变化
https://github.com/ionic-team/ionic-app-scripts/releases/tag/v2.0.0
必须修改src / index.html以包含新的供应商脚本标记。
... <body> <!-- Ionic's root component and where the app will load --> <ion-app></ion-app> <script src="cordova.js"></script> <!-- The polyfills js is generated during the build process --> <script src="build/polyfills.js"></script> <!-- all code from node_modules directory is here --> <script src="build/vendor.js"></script> <!-- The bundle js is generated during the build process --> <script src="build/main.js"></script> </body> ...
在< your application directory > /src/index.html
的脚本标记内添加vendor.js
path
<script src="build/vendor.js"></script>
还要在< your application directory >/src/service-worker.js
文件中进行更改 – 在precache
部分中包含vendor.js
:
// pre-cache our key assets self.toolbox.precache( [ './build/main.js', './build/vendor.js', // <=== Add vendor.js './build/main.css', './build/polyfills.js', 'index.html', 'manifest.json' ] );