我创建了一个android WebView,并javascript使用注入接口addJavascriptInterface(mObject, "jsinterface").它工作正常,直到我使用new运算符在JavaScript中创建具有相同名称(jsinterface)的对象.
WebView mWebView = findViewById(R.id.myWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new MyWebChromeClient((Activity)mContext));
mWebView.addJavascriptInterface(new testClass(), "jsinterface");
mWebView.loadUrl("UrlToLoad");
Run Code Online (Sandbox Code Playgroud)
public class testClass{
public testClass() {
}
@JavascriptInterface
public String testNativeMethod() {
return "Java method called!!";
}
}
Run Code Online (Sandbox Code Playgroud)
function test(msg){
this.message = msg;
this.testJSMethod = function(){
return this.message;
}
}
alert(jsinterface.testNativeMethod()); // prints Java method called!!
jsinterface= new test("JS method called...");
alert(jsinterface.testJSMethod()); // prints JS method called...
alert(jsinterface.testNativeMethod()); // errors "NPMethod called on non- NPObject" …Run Code Online (Sandbox Code Playgroud) 我想将在 PyCharm 中打开的项目中的所有文件的 CRLF 更改为 LF。我已更新项目设置以使用“文件 -> 设置 -> 编辑器 -> 代码样式”中的 LF 行分隔符,如果不打开这些文件,它不会更改现有文件。
有没有办法将 PyCharm 中所有现有文件的 CRLF 更改为 LF?