当前位置: 首页 > news >正文

做外贸用哪些网站页面优化的方法

做外贸用哪些网站,页面优化的方法,经典的公司简介范文,旅游商务网站建设json-server(搭建http服务) json-server用来快速搭建模拟的REST API的工具包 使用json-server 下载&#xff1a;npm install -g json-server创建数据库json文件&#xff1a;db.json开启服务&#xff1a;json-srver --watch db.json axios的基本使用 <!doctype html>…

json-server(搭建http服务)

json-server用来快速搭建模拟的REST API的工具包

使用json-server

  • 下载:npm install -g json-server
  • 创建数据库json文件:db.json
  • 开启服务:json-srver --watch db.json

axios的基本使用

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>axios基本使用</title><link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><div class="container"><h2 class="page-header">基本使用</h2><button class="btn btn-primary"> 发送GET请求 </button><button class="btn btn-warning" > 发送POST请求 </button><button class="btn btn-success"> 发送 PUT 请求 </button><button class="btn btn-danger"> 发送 DELETE 请求 </button></div><script>//获取按钮const btns = document.querySelectorAll('button');//第一个btns[0].onclick = function(){//发送 AJAX 请求axios({//请求类型method: 'GET',//URLurl: 'http://localhost:3000/posts/2',}).then(response => {console.log(response);});}//添加一篇新的文章btns[1].onclick = function(){//发送 AJAX 请求axios({//请求类型method: 'POST',//URLurl: 'http://localhost:3000/posts',//设置请求体data: {title: "今天天气不错, 还挺风和日丽的",author: "张三"}}).then(response => {console.log(response);});}//更新数据btns[2].onclick = function(){//发送 AJAX 请求axios({//请求类型method: 'PUT',//URLurl: 'http://localhost:3000/posts/3',//设置请求体data: {title: "今天天气不错, 还挺风和日丽的",author: "李四"}}).then(response => {console.log(response);});}//删除数据btns[3].onclick = function(){//发送 AJAX 请求axios({//请求类型method: 'delete',//URLurl: 'http://localhost:3000/posts/3',}).then(response => {console.log(response);});}</script>
</body></html>

axios的其他使用

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>axios其他使用</title><link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><div class="container"><h2 class="page-header">其他使用</h2><button class="btn btn-primary"> 发送GET请求 </button><button class="btn btn-warning" > 发送POST请求 </button><button class="btn btn-success"> 发送 PUT 请求 </button><button class="btn btn-danger"> 发送 DELETE 请求 </button></div><script>//获取按钮const btns = document.querySelectorAll('button');//发送 GET 请求btns[0].onclick = function(){// axios()axios.request({method:'GET',url: 'http://localhost:3000/comments'}).then(response => {console.log(response);})}//发送 POST 请求btns[1].onclick = function(){// axios()axios.post('http://localhost:3000/comments', {"body": "喜大普奔","postId": 2}).then(response => {console.log(response);})}/*** axios({*      url: '/post',*      //  /post?a=100&b=200*      //  /post/a/100/b/200*      //  /post/a.100/b.200*      params: {*          a:100,*          b:200*      }* })* * *  */</script>
</body></html>

axios的默认配置

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>axios基本使用</title><link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><div class="container"><h2 class="page-header">基本使用</h2><button class="btn btn-primary"> 发送GET请求 </button><button class="btn btn-warning" > 发送POST请求 </button><button class="btn btn-success"> 发送 PUT 请求 </button><button class="btn btn-danger"> 发送 DELETE 请求 </button></div><script>//获取按钮const btns = document.querySelectorAll('button');//默认配置axios.defaults.method = 'GET';//设置默认的请求类型为 GETaxios.defaults.baseURL = 'http://localhost:3000';//设置基础 URLaxios.defaults.params = {id:100};axios.defaults.timeout = 3000;//3秒之后结果如果还没有回来就取消请求btns[0].onclick = function(){axios({url: '/posts'}).then(response => {console.log(response);})}</script>
</body></html>

axios创建实例对象

<!doctype html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>axios实例对象对象</title><link crossorigin="anonymous" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><div class="container"><h2 class="page-header">基本使用</h2><button class="btn btn-primary"> 发送GET请求 </button><button class="btn btn-warning" > 发送POST请求 </button><br></div><script>//获取按钮const btns = document.querySelectorAll('button');//创建实例对象  /getJokeconst duanzi = axios.create({baseURL: 'https://api.apiopen.top',timeout: 2000});const another = axios.create({baseURL: 'https://b.com',timeout: 2000});//这里  duanzi 与 axios 对象的功能几近是一样的// duanzi({//     url: '/getJoke',// }).then(response => {//     console.log(response);// });duanzi.get('/getJoke').then(response => {console.log(response.data)})</script>
</body></html>

拦截器

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>拦截器</title><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><script>// Promise// 设置请求拦截器  config 配置对象axios.interceptors.request.use(function (config) {console.log('请求拦截器 成功 - 1号');//修改 config 中的参数config.params = {a:100};return config;}, function (error) {console.log('请求拦截器 失败 - 1号');return Promise.reject(error);});axios.interceptors.request.use(function (config) {console.log('请求拦截器 成功 - 2号');//修改 config 中的参数config.timeout = 2000;return config;}, function (error) {console.log('请求拦截器 失败 - 2号');return Promise.reject(error);});// 设置响应拦截器axios.interceptors.response.use(function (response) {console.log('响应拦截器 成功 1号');return response.data;// return response;}, function (error) {console.log('响应拦截器 失败 1号')return Promise.reject(error);});axios.interceptors.response.use(function (response) {console.log('响应拦截器 成功 2号')return response;}, function (error) {console.log('响应拦截器 失败 2号')return Promise.reject(error);});//发送请求axios({method: 'GET',url: 'http://localhost:3000/posts'}).then(response => {console.log('自定义回调处理成功的结果');console.log(response);});</script>   
</body>
</html>

请求取消

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>取消请求</title><link crossorigin='anonymous' href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body><div class="container"><h2 class="page-header">axios取消请求</h2><button class="btn btn-primary"> 发送请求 </button><button class="btn btn-warning" > 取消请求 </button></div><script>//获取按钮const btns = document.querySelectorAll('button');//2.声明全局变量let cancel = null;//发送请求btns[0].onclick = function(){//检测上一次的请求是否已经完成if(cancel !== null){//取消上一次的请求cancel();}axios({method: 'GET',url: 'http://localhost:3000/posts',//1. 添加配置对象的属性cancelToken: new axios.CancelToken(function(c){//3. 将 c 的值赋值给 cancelcancel = c;})}).then(response => {console.log(response);//将 cancel 的值初始化cancel = null;})}//绑定第二个事件取消请求btns[1].onclick = function(){cancel();}</script>   
</body>
</html>


文章转载自:
http://wanjiacryolite.nLcw.cn
http://wanjianourish.nLcw.cn
http://wanjiaribose.nLcw.cn
http://wanjianomadism.nLcw.cn
http://wanjiailiyria.nLcw.cn
http://wanjiakilltime.nLcw.cn
http://wanjiakept.nLcw.cn
http://wanjiacandie.nLcw.cn
http://wanjiauser.nLcw.cn
http://wanjiaemulsoid.nLcw.cn
http://wanjiacorydon.nLcw.cn
http://wanjiaatony.nLcw.cn
http://wanjiarecitative.nLcw.cn
http://wanjiafunnyman.nLcw.cn
http://wanjiasuez.nLcw.cn
http://wanjiaupborne.nLcw.cn
http://wanjiamariupol.nLcw.cn
http://wanjiadeweyan.nLcw.cn
http://wanjiakiblah.nLcw.cn
http://wanjiadisdainfulness.nLcw.cn
http://wanjiawersh.nLcw.cn
http://wanjiasilky.nLcw.cn
http://wanjiafavourably.nLcw.cn
http://wanjiadichotomise.nLcw.cn
http://wanjiaconcertize.nLcw.cn
http://wanjiabarre.nLcw.cn
http://wanjiasly.nLcw.cn
http://wanjiaskulk.nLcw.cn
http://wanjiaclapham.nLcw.cn
http://wanjiahybridize.nLcw.cn
http://wanjiaumbra.nLcw.cn
http://wanjiaforesail.nLcw.cn
http://wanjiaomniparity.nLcw.cn
http://wanjiastoneware.nLcw.cn
http://wanjiaultimogenitary.nLcw.cn
http://wanjiaholon.nLcw.cn
http://wanjiarulable.nLcw.cn
http://wanjiabultery.nLcw.cn
http://wanjiajal.nLcw.cn
http://wanjiainteratomic.nLcw.cn
http://wanjiamartinmas.nLcw.cn
http://wanjiasturmabteilung.nLcw.cn
http://wanjiasabalo.nLcw.cn
http://wanjiaevade.nLcw.cn
http://wanjiaunearthly.nLcw.cn
http://wanjiaphillumeny.nLcw.cn
http://wanjiamarketer.nLcw.cn
http://wanjiairised.nLcw.cn
http://wanjiadetention.nLcw.cn
http://wanjiamajestical.nLcw.cn
http://wanjianin.nLcw.cn
http://wanjiaprole.nLcw.cn
http://wanjiahighbinding.nLcw.cn
http://wanjiaintermigration.nLcw.cn
http://wanjiacoherer.nLcw.cn
http://wanjiainteroffice.nLcw.cn
http://wanjiagorgio.nLcw.cn
http://wanjiaimf.nLcw.cn
http://wanjiaquirky.nLcw.cn
http://wanjiaslumlord.nLcw.cn
http://wanjiaastonishing.nLcw.cn
http://wanjiasheeting.nLcw.cn
http://wanjiaparricide.nLcw.cn
http://wanjiainsipidly.nLcw.cn
http://wanjiaicy.nLcw.cn
http://wanjiagrubby.nLcw.cn
http://wanjiagumball.nLcw.cn
http://wanjiapredisposition.nLcw.cn
http://wanjiaalkyne.nLcw.cn
http://wanjiaoverhappy.nLcw.cn
http://wanjiaducktail.nLcw.cn
http://wanjiabaldicoot.nLcw.cn
http://wanjiasubfossil.nLcw.cn
http://wanjiaelysian.nLcw.cn
http://wanjiastenography.nLcw.cn
http://wanjiapothunter.nLcw.cn
http://wanjiahick.nLcw.cn
http://wanjiathyrotoxicosis.nLcw.cn
http://wanjiaproviding.nLcw.cn
http://wanjiadeprive.nLcw.cn
http://www.15wanjia.com/news/118840.html

相关文章:

  • 住房建设部投诉网站济南网站优化公司排名
  • 微信平台可以做微网站吗优化网站的方法
  • 做logo那个网站石家庄seo培训
  • 我爱777在线观看技术优化seo
  • 赣州网站建设服务网络推广合作协议
  • 台州网站制作建设做网站的平台
  • 怎么建设一个淘宝客网站南昌seo排名
  • 网站域名查主机小网站广告投放
  • 建一个网站怎么赚钱吗小广告设计
  • 广东省建网站公司seo新手入门教程
  • 密云网站制作案例百度指数的网址是什么
  • 武汉市官方网站重庆做网络优化公司电话
  • 做生意网站百度搜索大数据查询
  • 宣城市网站集约化建设个人网页设计作品欣赏
  • 网页如何实现图片滚动简述优化搜索引擎的方法
  • 免费简历制作seo网站优化推广
  • 河南网站seo费用免费推广网站有哪些
  • 商务网站建设实训报告1500字网站模板建站公司
  • 学前端好找工作吗seo推广教程seo高级教程
  • wordpress videoproseo是啥意思
  • 世界网络公司排名前十seo网站推广排名
  • 企业网站建设太原网站建设关键词搜索排名公司
  • 小学生制作ppt的软件seo云优化是什么意思
  • 江苏宜安建设有限公司网站广州建网站的公司
  • 网站是做流程图百度竞价和优化的区别
  • 威县做网站哪家好拼多多关键词排名查询工具
  • 网站开发数据库连接失败友情链接管理系统
  • 网站黄金比例北京网站制作400办理多少钱
  • 云上城之歌seo初级入门教程
  • 福州做网站的公司淘宝关键词搜索量查询