您需要在主视图中为您的文章设置一个占位符,例如Div contentArea下方。除此之外,还需要重写showRouterLayoutContent(..)方法。
@Route("")
public class MainView extends Main implements RouterLayout {
private Div contentArea = new Div();
public MainView(@Value("${env}") String env, @Autowired BuildProperties buildProperties) {
HeaderComponent header = new HeaderComponent(env, Application.APP_NAME, buildProperties.getVersion());
FooterComponent footer = new FooterComponent(env, buildProperties.getVersion())
add(header, contentArea, footer);
}
@Override
public void showRouterLayoutContent(HasElement content) {
contentArea.getElement().appendChild(content.getElement());
}
}