Blogger Information
Blog 29
fans 0
comment 0
visits 19469
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
npm 安装与删除包的常用操作及 node中的模块声明,导出与导入
千里马遇伯乐
Original
680 people have browsed it

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial- scale=1.0">
  7. <title>Document</title>
  8. <script src="https://unpkg.com/vue@next"></script>
  9. <style>
  10. button{
  11. background-color: red;
  12. font-size: 32px;
  13. color: rgb(245, 241, 241);
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <button onclick="getData()">fecth</button>
  19. <button onclick="getDataOne()">await</button>
  20. <script>
  21. //1. 实例演示fetch api, async,await的使用
  22. function getData() {
  23. fetch("http://xhr411.edu/users.php")
  24. .then((response) => response.json())
  25. .then((json) => console.log(json));
  26. }
  27. const url = "http://xhr411.edu/users.php";
  28. async function getDataOne(){
  29. const response = await fetch(url);
  30. const result = await response.json();
  31. console.log(result);
  32. }
  33. </script>
  34. </body>
  35. </html>

node中的模块声明,导出与导入

  1. // 1. 核心模块
  2. const http = require('http');
  3. console.log(http);
  4. // 2. 文件模块
  5. const demo = require('./demo.js');
  6. console.log(demo.getuser())
  7. let user = "php.cn";
  8. function getuser(){
  9. return this.user;
  10. }
  11. exports.user = user;
  12. exports.getuser = getuser;
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post