简体   繁体   English

尝试在 Cordova 上使用 JavaScript 在 IOS 模拟器上运行 Ionic Core 时出现问题

[英]Issue when trying to run Ionic Core on Cordova with JavaScript on IOS Simulator

I have decided to use Ionic Core due to the fact of me not needing to use Frameworks like Vue, Angular and React.我决定使用 Ionic Core,因为我不需要使用 Vue、Angular 和 React 等框架。

I have created a project using Cordova and installed @ionic/core with npm to create the files that would otherwise use a CDN.我使用 Cordova 创建了一个项目,并使用 npm 安装了 @ionic/core 以创建否则将使用 CDN 的文件。

However, I have included them into my index.html application with an h1 tag saying Hello World, this does not appear on the IOS Simulator using XCode.但是,我已将它们包含在我的 index.html 应用程序中,并带有一个名为 Hello World 的 h1 标签,这不会出现在使用 XCode 的 IOS 模拟器上。 I do not get any error messages, it just shows a blank white screen.我没有收到任何错误消息,它只是显示一个空白的白屏。

This leads me to believe that this could be due to me not initialising the Ionic Core javascript file.这让我相信这可能是因为我没有初始化 Ionic Core javascript 文件。

Here is my index.html file:这是我的 index.html 文件:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="module" src="core/dist/ionic/ionic.esm.js"></script>
    <script nomodule src="core/dist/ionic/ionic.js"></script>
    <link href="core/css/ionic.bundle.css" rel="stylesheet">
</head>

<body>
    <h1>Hello World</h1>
</body>

</html>

Here is my project directory shown using VSCode:这是我使用 VSCode 显示的项目目录:

项目目录

No errors are shown on XCode nor on the Cordova side of things when launching it with cordova run ios使用 cordova 运行 Z9E304D4E8DF1B74CFAZ0094

I cannot launch with Ionic as I am only using the Javascript files not the actual CLI我无法使用 Ionic 启动,因为我只使用 Javascript 文件而不是实际的 CLI

Try using Ionic Core is by adding a script tag to the CDN:尝试使用 Ionic Core 的方法是向 CDN 添加脚本标签:

<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<link href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css" rel="stylesheet">

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

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