如何在网络上托管Ionic应用程序? [英] How to host an Ionic app in web?

查看:138
本文介绍了如何在网络上托管Ionic应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的目标网页网站上创建了一个非常简单的应用模拟器。我在本地执行此操作的方式是在我的目标网页的index.html中运行(离子服务)应用程序通过这样的iframe:

I created a very simple simulator of my app in my landing page website. The way i do it locally is in the index.html of my landing page i run (ionic serve) the app through an iframe like this:

<iframe src="http://localhost:8100/#/tab/home"></iframe>

我的问题是如何在我的网络托管中上传源时引用来源。

My problem is how do I reference the source when i upload it in my web hosting.

我的文件结构如下所示

   x myLandingPage
     >index.html //landing page
     x mysimulator
       x www
         x templates
           >index.html //ionic app


推荐答案

编辑:Ionic 1.2正式支持部署为网站

edit: Ionic 1.2 officially supports deployment as a website!

让我们假设您的网站托管在 example.com 域,并且您的服务器根目录中有一个名为 myLandingPage 的文件夹并且您可以通过 http://example.com/myLandingPage/index.html 在线访问它。在这种情况下,您将在 index.html 文件中使用以下 iframe 标记:

Let's assume your site is hosted at example.com domain and that you have a folder called myLandingPage at the root of your server and that you can access it online via http://example.com/myLandingPage/index.html. In that case you would use the following iframe tag in your index.html file:

<iframe src="mysimulator/www/templates/index.html"></iframe>

因此,一旦您将应用程序上传到您的托管服务器,您就不必运行 ionic serve ,因为当您在本地执行此操作时,您实际上会启动一个本地Web服务器,然后提供此内容。将文件上传到服务器后,当然不需要步骤。

So, once you upload your app to your hosting, you won't have to run ionic serve, because when you do that locally you actually start a local web server which then serves this content. Once you upload your files to your server that step is then of course not needed.

希望这会有所帮助。顺便说一句,我看到有一件事看起来与标准的离子设置有点不同,那就是你的index.html文件在templates文件夹中的位置。通常它在www文件夹中。因此,如果您在文件结构中放错了文件,可能是src将

Hope this helps. Btw, I see one thing that looks a bit off from the standard Ionic setting and that is the placement of your index.html file inside the templates folder. Usually it is in the www folder. So, in case you misplaced the file in the file structure it could be that the src will be

<iframe src="mysimulator/www/index.html"></iframe>

但我希望你能明白这一点,并且能够找到自己的方式。

but I hope you get the point and will be able to find your way.

这篇关于如何在网络上托管Ionic应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆