一、下载安装
官网:https://developer.mozilla.org/zh-CN/docs/Web/API/Fetch_API
二、使用
<!DOCTYPE html><html lang="zh"><head><meta charset="UTF-8"><title>TestAjax</title></head><body><button>发送请求</button><script>const btn = document.querySelector('button');btn.onclick = function (){fetch('http://localhost:8000/fetch',{method : 'POST',headers:{name:'mx'},body:'username=admin&password=admin',}).then(response => {// return response.text();return response.json();}).then(response=>{console.log(response);});}</script></body></html>
