后端:
1.新建一个文件夹
2.通过npm init创建package.json文件
3.通过 npm install express 安装express模块
4.在node文件夹中新建app.js文件
5.npm install mysql 连接mysql数据库
var express=require('express');
var app =express();
var mysql = require('mysql');
//设置跨域访问
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow- Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1');
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
var arr=[];
// 连接数据库
var connection = mysql.createConnection({
host : '121.22.124.225',
user : 'test',
password : '123',
database : 'rebuild'
});
connection.connect()
//SQL语句查询
connection.query(&