后端: 引入对象,获取参数const koaCors = require('koa-cors');创建对象:app.use(koaCors());
前端: 请求数据 (向后端)<script>$(function(){$.ajax({url:"http://localhost:5500/tag",type:"GET",success:function(res){if(res.status===200){const data = res.data;let html = ""; ``for (let index = 0; index < data.length; index++) {const element = data[index];html += element.text + "  ";}$(".col-xs-12").html(html); ``}console.log(res);},error:function(err){console.log(err);}})})</script>
给html赋值一个空let html = "";给HTML里添加数据html += element.text + "  ";引用HTML里的数据并显示$(".col-xs-12").html(html);