我正在尝试在加载页面时进行简单的向下滚动。
@Route("somthing")
public class SomeView extends VerticalLayout{
public SomeView(){
...
Adding some Elements
...
UI.getcurrent().getPage().executeJs("window.scroll(0,300)");
}
}
我还尝试将侦听器添加到窗口:
UI.getcurrent().getPage().executeJs("window.addEventListener('onload',function(){console.log('trigger');window.scroll(0,300);});");
但是在两种情况下,加载页面时都不会发生任何事情。