How to print to the console in GWT

前端 未结 10 1127
广开言路
广开言路 2020-12-23 14:29

I am debugging a GWT application and I need to print some stuff to the console for testing purposes. System.out.println and GWT.log don\'t work. Do

10条回答
  •  不知归路
    2020-12-23 14:50

    To log to browsers console you can do it using native, in a very simple way. Very helpful in debugging.

    If you add a native method like in below, you can send a string to it from where you want and it will log it in the browsers console.

    public static native void console(String text)
    /*-{
        console.log(text);
    }-*/;
    

    For more information about using native in GWT: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html

提交回复
热议问题