app.component.html
<nav>
<a routerLink="/dashboard"></a>
<a routerLink="/reports"></a>
<nav>
<main role="main" class="page-container">
<router-outlet></router-outlet>
</main>
APP-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ReportsComponent } from './reports/reports.component';
const routes: Routes = [
{ path: 'dashboard', component: DashboardComponent },
{ path: 'reports', component: ReportsComponent },
{ path: '',
redirectTo: '/dashboard',
pathMatch: 'full'
}];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ReportsComponent } from './reports/reports.component';
@NgModule({
declarations: [
AppComponent,
DashboardComponent,
ReportsComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
使用上面的代码,我看到点击导航链接后,我可以导航到相应的组件,但由于某种原因,URL没有得到更新。
不确定我是否遗漏了一些非常基本的东西。请帮忙。
答案 0 :(得分:2)
如果您正在运行混合应用程序(使用升级模块),请将useHash添加到路由器配置
$meta_boxes[] = array(
'id' => 'untitled',
'title' => esc_html__( 'Untitled Metabox', 'metabox-online-generator' ),
'post_types' => array( 'post', 'page' ),
'context' => 'advanced',
'priority' => 'default',
'autosave' => false,
'fields' => array(
array(
'id' => $prefix . 'fieldset_text_1',
'type' => 'fieldset_text',
'name' => esc_html__( 'Profit', 'metabox-online-generator' ),
'rows' => 6,
'options' => array(
'Selling Price' => 'Selling Price',
'Product Cost' => 'Product Cost',
'Shipping' => 'Shipping',
'Profit margin' => 'Profit margin',
'CPA' => 'CPA',
'NET' => 'NET',
),
),
),
);
return $meta_boxes;