方法一: 代码示例: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> function test(){ console.log("hello world!"); } </script> </head>