简体   繁体   English

浏览器平台的ionic 2无法正常工作

[英]ionic 2 for browser platform is not working

I want to create an app which is able to run in mobile phone and also in browser (of course no device dependency functions). 我想创建一个能够在手机和浏览器中运行的应用程序(当然没有设备依赖功能)。 Here are the steps: 步骤如下:

ionic start --v2 demo blank 离子开始--v2演示空白

cd demo 光盘演示

ionic platform add browser 离子平台添加浏览器

ionic build browser 离子构建浏览器

cd platforms/browser cd平台/浏览器

php -S localhost:8000 的PHP -S本地主机:8000

Then open localhost:8000 in browser. 然后在浏览器中打开localhost:8000。

在此处输入图片说明

I looked through the ionicframework document. 我浏览了ionicframework文档。 There is nothing about platform browser . 平台浏览器无关。 Can anybody advise how I can run my app in browser? 有人可以建议我如何在浏览器中运行我的应用程序吗? Thanks. 谢谢。

You don't need to add the browser platform, just run ionic serve : 您无需添加浏览器平台,只需运行ionic serve

ionic start --v2 demo blank

cd demo

ionic serve

Further information can be found here . 可以在此处找到更多信息。

如果要运行浏览器平台,请使用cd platforms/browser/www而不是cd platforms/browser ,然后从那里运行本地服务器。

From the official documentation ionic2 , its clear that the platform can either be ios or android as shown below screenshot. ionic2官方文档中可以清楚地看出,该平台可以是ios或android,如下图所示。

在此处输入图片说明

So, when you want to render it in a browser, you can simply use 因此,当您想在浏览器中呈现它时,只需使用

ionic serve 

Perform the following code at the root of the project and then the web-browser based version will be generated at /www/ folder including the sub-directories such as assets , build & index.html which is the main point of entry for the web app. 在项目的根目录执行以下代码,然后将在/www/文件夹中生成基于Web浏览器的版本,其中包括子目录(例如assetsbuildindex.html ,这是Web的主要入口点应用程式。

If you wanna have the app packaged as a staging or production bundle, the following command can be used, which will again generate the prod build at the same /www/ location. 如果您想将应用程序打包为临时产品包或生产包,则可以使用以下命令,该命令将再次在相同的/www/位置生成prod版本。

npm run ionic:build --prod

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

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