node前端常用
目录
node前端常用
目的
- 了解nodejs
- 了解后端—>读取本地文件—>连接数据库—>响应请求
- 了解api接口文档
检测是否有node
node -v
初始化项目
- 切换到项目目录
- npm init -y
使用第三方模块
1.安装模块
npm i axios -S
2.导入模块
const axios=(axios)
3.使用模块
axios.get(url).then(res=>{})
使用自定义模块
1.定义模块
module.exports={
max(){},
randomStr(){}
}
2.导入模块
const utils==require('./utils.js')
3.使用模块
utils.max()
utils.randomStr()
项目运行
一、配置命令
- package.json->script
- “serve”:“node main.js”
- npm run serve
二、cmd
1.进入项目目录(cd 路径)
2.node main.js
mysql命令(前端常用)
一、查询
1.查询feedback中所有的信息
SELECT *FROM "feedback ` WHERE 1;
2.指定列查询
SELECT 'msg ', 'name `FROM `baizee` WHERE 1;
3.添加查询条件
select * from feedback where name='小白";
4查询msg中包含山的元素 (%代表是任意字符)
select * from baizee where msg like '%好%'
5.查询msg中包含山的元素 (…%代表以…结尾 _代表任意一个字符串)
select * from baizee where msg like '还_错%'
6.desc按时间排序降序
select * from baizee where 1 order by `datetime '
7.查询偏移2个截取3行
select * from baizee where 1 order by 'datetime ` desc limit2,3
明天再补。。。。