[英]how to find out whole function of a class in java script
I'm sending a class to my site using android web view just like this: webView.addJavascriptInterface(data, "info")
I wanted to know is there any way that I find out what functions and what variables are there in info class on the web side? I'm sending a class to my site using android web view just like this:
webView.addJavascriptInterface(data, "info")
I wanted to know is there any way that I find out what functions and what variables are there in info class on web 方面? for example, if my data class be like this:例如,如果我的数据 class 是这样的:
class Data(){
val name = ""
val family = ""
fun getName():String = name
fun getFamily():String = family
}
what javascript code I should use to understand the info class has two variables name and family?我应该使用什么 javascript 代码来理解信息 class 有两个变量名称和系列? currently, my web side is just like this:
目前,我的 web 端是这样的:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
document.write(info.getName());
</script>
</body>
</html>
and using that I can access to name variable which is passed by android side, how can I understand also there is a getFamily function too?并且使用它我可以访问由 android 端传递的名称变量,我怎么能理解还有一个 getFamily function 呢?
you can use a built-in method of javascript you can get the whole method of an object object.keys(name_of_object)
.您可以使用 javascript 的内置方法,您可以获得 object
object.keys(name_of_object)
的整个方法。
for example, in your case, it would be like this例如,在你的情况下,它会是这样的
document.write(object.keys(info));
and It will print getName()
and getFamily()
它将打印
getName()
和getFamily()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.