Ng build Angular 2 Cli应用程序404硬刷新时出错
使用Ng build Angular 2 Cli应用程序404硬刷新时出错,ng-build,Ng Build,使用ng build构建时,构建成功,可以访问应用程序 但是,当在生产模式中使用以下命令时: ng build --prod 这给了我一个错误: “TypeError:无法将未定义或null转换为对象” 为apache2添加.htaccess文件并在文件中插入代码 RewriteEngine on # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_
ng build
构建时,构建成功,可以访问应用程序
但是,当在生产模式中使用以下命令时:
ng build --prod
这给了我一个错误:
“TypeError:无法将未定义或null转换为对象”
为apache2添加.htaccess文件并在文件中插入代码
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
和index.html文件change base href
index.html
<base href="/angular/">
这里是目录
然后打开/etc/apache2/sites enabled/000-default.conf文件,并在
标记上添加以下规则
<Directory "/var/www/html">
AllowOverride All
</Directory>
允许超越所有