本文介绍了离子 2: ReferenceError: webpackJsonp 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Ionic 的新手.我已经用超级模板开始了项目.但是当我尝试在浏览器中运行该应用程序时.它抛出一个错误说:

I'm new to Ionic. I have started project with super template. But when I try to run the app in browser. It throws an error saying:

ReferenceError: webpackJsonp is not defined
    at http://localhost:8100/build/main.js:1:1

我曾尝试将 vendor.js 放在 index.html 中,但没有奏效.

I have tried putting vendor.js in index.html but that has not worked.

这是 index.html 文件.我已经删除了 vendor.js,因为它不起作用.

Here's the index.html file. I have removed vendor.js as it didn't work.

<!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 脚本 - 现在它在本地运行.

Literally just went through the same thing as you are. I added the vendor.js script BEFORE the main.js in /src/index.html - now it runs locally.

  <!-- 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>

这篇关于离子 2: ReferenceError: webpackJsonp 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 03:07