修改Angular路由模式为hash模式

东明兄 2019-01-05
0条评论 3,627 次浏览
东明兄 2019-01-050条评论 3,627 次浏览

spa 应用一般有html5 history模式和hash模式,angular 默认是 history 模式,修改为hash 的方法:

import {HashLocationStrategy, LocationStrategy} from '@angular/common';
providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],

重新运行项目即可

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注