页面加载角度



我正在angular中做一个个人项目,我想创建一个页面,每当我打开网站时,这个屏幕会出现几秒钟,然后重定向到主页组件。或者创建一个页面,在后台加载网站时显示几秒钟

app.routing ***

const routes: Routes = [
{path: "", redirectTo:"home", pathMatch:"full"},
{path: "home", component: HomeComponent},
{path: ":id", component: OverviewComponent},
{path: ":id/:id", component: OverviewComponent},
{path: ":id/:id/:id", component: OverviewComponent},
{path: ":id/:id/:id/:id", component: OverviewComponent},
{path: ":id/:id/:id/:id/:id", component: OverviewComponent},
{path: "**", redirectTo:"home"}

];

您的index.html可以像一样

<body>
<app-root>
<img class="logo" src="assets/logo.jpg">
</app-root>
</body>

因此,当你加载应用程序时;徽标";显示

您也可以在引导应用之前更改您的main.ts以等待

const timer=new Promise((resolve, reject) => {
setTimeout(() => {
resolve("ready")
}, 2000)
})
timer.then(_=>{
platformBrowserDynamic().bootstrapModule(AppModule).then(ref => {
// Ensure Angular destroys itself on hot reloads.
if (window['ngRef']) {
window['ngRef'].destroy();
}
window['ngRef'] = ref;

// Otherwise, log the boot error
}).catch(err => console.error(err));
})

相关内容

  • 没有找到相关文章

最新更新