我正在开展角度4项目,我将之前的MVC项目前端转换为角度。
我面临的问题是我们的基本网址不是静态的,可以是我们在MVC路由映射器中的任何东西(字符串)。我尝试了角度,但它不起作用。
我尝试了下面的路由表。
const appRoutes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: '**', component: RewardComponent },
{ path: '**/**', component: RewardComponent }
]
现在我尝试跑步。
http://localhost:50525/home - 这很好用
http://localhost:50525/ {anything} - 工作正常
但是一旦我达到更高级别,我就会收到错误。
http://localhost:50525/ {什么} / {任何}
我收到以下错误...
zone.js:2933 GET http://localhost:50525/homeasadd/app/main.js 404 (Not Found)
scheduleTask @ zone.js:2933
ZoneDelegate.scheduleTask @ zone.js:411
Zone.scheduleTask @ zone.js:236
Zone.scheduleMacroTask @ zone.js:259
(anonymous) @ zone.js:2966
proto.(anonymous function) @ zone.js:1366
fetchTextFromURL @ system.src.js:1051
(anonymous) @ system.src.js:1778
ZoneAwarePromise @ zone.js:890
(anonymous) @ system.src.js:1777
(anonymous) @ system.src.js:2806
(anonymous) @ system.src.js:3384
(anonymous) @ system.src.js:3707
(anonymous) @ system.src.js:4099
(anonymous) @ system.src.js:4562
(anonymous) @ system.src.js:4831
(anonymous) @ system.src.js:407
ZoneDelegate.invoke @ zone.js:392
Zone.run @ zone.js:142
(anonymous) @ zone.js:873
ZoneDelegate.invokeTask @ zone.js:425
Zone.runTask @ zone.js:192
drainMicroTaskQueue @ zone.js:602
Promise resolved (async)
scheduleMicroTask @ zone.js:585
ZoneDelegate.scheduleTask @ zone.js:414
Zone.scheduleTask @ zone.js:236
Zone.scheduleMicroTask @ zone.js:256
scheduleResolveOrReject @ zone.js:871
ZoneAwarePromise.then @ zone.js:981
(anonymous) @ system.src.js:4789
import @ system.src.js:839
(anonymous) @ system.src.js:1801
(anonymous) @ (index):10
(index):10 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:50525/homeasadd/app/main.js
Error: XHR error (404 Not Found) loading http://localhost:50525/homeasadd/app/main.js
at XMLHttpRequest.wrapFn (http://localhost:50525/node_modules/zone.js/dist/zone.js:1166:39)
at ZoneDelegate.invokeTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:425:31)
at Zone.runTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:192:47)
at ZoneTask.invokeTask [as invoke] (http://localhost:50525/node_modules/zone.js/dist/zone.js:499:34)
at invokeTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:1540:14)
at XMLHttpRequest.globalZoneAwareCallback (http://localhost:50525/node_modules/zone.js/dist/zone.js:1566:17)
Error loading http://localhost:50525/homeasadd/app/main.js
at XMLHttpRequest.wrapFn (http://localhost:50525/node_modules/zone.js/dist/zone.js:1166:39)
at ZoneDelegate.invokeTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:425:31)
at Zone.runTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:192:47)
at ZoneTask.invokeTask [as invoke] (http://localhost:50525/node_modules/zone.js/dist/zone.js:499:34)
at invokeTask (http://localhost:50525/node_modules/zone.js/dist/zone.js:1540:14)
at XMLHttpRequest.globalZoneAwareCallback (http://localhost:50525/node_modules/zone.js/dist/zone.js:1566:17)
Error loading http://localhost:50525/homeasadd/app/main.js

就像试图在{anything folder。}
中找到maion.js一样我甚至不确定两个级别的路由是否可以角度,因为我不熟悉这些。
system.js中main,js的位置设置如下
app: {
main: 'main.js', defaultExtension: 'js'
},
提前感谢您的帮助,我希望我在帖子中写的对于理解我的问题有帮助!