如何使用由angular

如何使用由angular

本文介绍了Angular 2 CLI-如何使用由angular-cli ng创建的/dist文件夹文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ng构建之后,我正在生成dist文件夹,并且我的目录看起来像

I'm generating dist folder after ng build and my directory looks like

C:\Source\angular> ng build

剪切并越过dist文件夹到另一个目录

cut and past the dist folder in another directory

C:\ReSource\angularbuild

将Index.html更改为

After changing in Index.html to

<base href="./ReSource/angularbuild/dist">

然后

C:\Source\angular> ng serve

获取inline.bundle.js,main.bundle.js,styles.bundle.js,vendor.bundle.js,main.bundle.js 404找不到错误

Getting inline.bundle.js,main.bundle.js,styles.bundle.js,vendor.bundle.js,main.bundle.js 404 not found errors

我该如何实现?我想运行从C:\Source\angular>

How could i achieve it ? I want to run the dist folder which is placed in angularbuild folder from C:\Source\angular>

让我知道正确的方法.

推荐答案

在ng构建之后,它只需要一个服务器来执行它,而不是ng serve,您可以从终端npm i -g http-server --save上安装一个http服务器,然后执行使用命令(y)从dist文件夹进行项目:

After ng build, it just needs a server to execute it, instead of ng serve you can install an http-server from your terminal npm i -g http-server --save then execute your project from the dist folder using the command (y) :

http-server ./dist

或者在使用Wamp或Xamp的apache上,例如,只需将整个文件复制到www文件夹内的dist文件夹中,然后重新启动Apache服务

Or on apache for who are using Wamp or Xamp for example just copy the entire files on the dist folder inside your www folder, then restart Apache service

这篇关于Angular 2 CLI-如何使用由angular-cli ng创建的/dist文件夹文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 11:08