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;

更多相关文章

  1. 异步请求、 npm 与 node模块的学习
  2. fetch api,npm 与 node 模块的使用
  3. fetch api, async,await的使用,npm 安装与删除包,node模块的导出
  4. 实例演示fetch api, async,await的使用 & npm 安装与删除包的常
  5. 在Unity中调用Android
  6. Android(安卓)Build 系统
  7. 【转】android编译系统的makefile文件Android.mk写法
  8. laravel 实现划分admin和home 模块分组
  9. Android(安卓)实现简单的插件化模块化.

随机推荐

  1. 学习SQL Server 2005不得不看的一些图书(
  2. 使用PDO创建长插入SQL查询的最佳方法
  3. 怪异问题!sql在pl/sql中执行结果与java jd
  4. sqlserver2005 express 未指定的错误 MS
  5. (1) PHP 使用 PDO 连接ORACLE、MYSQL、和S
  6. Mysql中插入数据并返回id插入到下一张表
  7. linux下mysql开启远程访问权限及防火墙开
  8. 《MySQL基础知识》笔记
  9. SQL语句字符串
  10. 内网安装mysql主从服务,mysql版本5.6.38-w