diff --git "a/\346\236\227\347\216\211\346\225\217/20240408_\345\211\215\345\220\216\347\253\257\350\277\236\346\216\245.md" "b/\346\236\227\347\216\211\346\225\217/20240408_\345\211\215\345\220\216\347\253\257\350\277\236\346\216\245.md" new file mode 100644 index 0000000000000000000000000000000000000000..6b0a6faab993f968cc49961b075a6aac66eecb4a --- /dev/null +++ "b/\346\236\227\347\216\211\346\225\217/20240408_\345\211\215\345\220\216\347\253\257\350\277\236\346\216\245.md" @@ -0,0 +1,48 @@ +# 前端 +```html + + + +``` +```js +// +function btnDelete(id) { + if (confirm('确认删除')) { + // axios.delete(请求的url).then(res=>对res.data获取返回的数据) + axios.delete(`${config.url}/${id}`).then(res => { + // 代码块 + }) + } +} +/* +add与update1为同一个html页面,通过是否携带动态参数区分 + +此html预加载完成时,需要通过函数分解请求路径,获取params对象 +再判断动态参数是否存在 + 若存在,则为update需渲染默认数据 + 若不存在,则为add +点击提交按钮时,需要参数判断,存在调用update代码,不存在则调用add代码 +*/ +function btnSave() { + let obj = { name, price, count } + let params = getQueryString() + let id = params.id * 1 + console.log('id:', id); + if (id > 0) { + axios.put(`${config.url}/${id}`, obj).then(res => { + }) + } else { + // 发送请求,与请求数据 + axios.post('http://localhost:3000/goods', obj).then(res => { + }) + } +} +// 给location.href赋值,进行页面跳转 +function btnAdd() { + location.href = './edit.html' +} +// axios发送put/post时,如果要发送数据,则axios.post(url,data).then() +axios.post('http://localhost:3000/search', obj).then(res => { + // 代码块 +}) +``` \ No newline at end of file diff --git "a/\346\236\227\347\216\211\346\225\217/20240409_\345\237\272\347\241\200\344\275\277\347\224\250.md" "b/\346\236\227\347\216\211\346\225\217/20240409_\345\237\272\347\241\200\344\275\277\347\224\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..5865fe108619c0dccf3e0db25ca5528d865e1c58 --- /dev/null +++ "b/\346\236\227\347\216\211\346\225\217/20240409_\345\237\272\347\241\200\344\275\277\347\224\250.md" @@ -0,0 +1,9 @@ +# axios使用 +res.data可以获取返回的数据 +axios.get(url).then(res=>{}) +axios.post/put(url,data) =>data发送请求数据 +# 挂载中间件 +使用async与await +app.use(async(ctx,next)=>{....await next()}) +# pgAdmin +https://baijiahao.baidu.com/s?id=1777159600925095509&wfr=spider&for=pc \ No newline at end of file