可以参考下这篇博客
https://blog.csdn.net/weixin_41620505/article/details/88758179
我这里只说一点test名字是随意取的,js调用时的形式应该是window.test.xxx 其中xxx是原生的方法webView.addJavascriptInterface(this, "test");