要在名称为字符串的情况下执行JavaScript函数,可以按名称访问类方法
<html> <body> <script> class Demo { methodOne(){ document.write("50"); } methodTwo(){ this['methodOne'](); document.write("<br> 100"); } } let num = new Demo(); num['methodTwo'](); </script> </body> </html>
友情链接: json在线解析 通晓查询 糯晒黄历 姓名打分