Reviewing node.js needs to pay attention to the knowledge points–(emphasis) span>
2.1:Parameters Pass and get the shape
Client scaffolding(发) (Parameter passing ) Node.js(收)< /p>
–发ajax this.axios.get(“http://127.0.0.1:3000/list?id=9&age=19″)
–receive node.js req(request request object )
var id = parseInt( req.query.id);
var age = parseInt(req.query.age);
error:node.js NaN Parameter error
2.2:Complete one Which function to useSQL node.js
(1)Login:
–Parameters:Username and passworduname upwd
-sql :SELECT uname,upwd FROM xz_login
WHERE uname =? AND upwd = md5(?)
Wrong username or passwordresult.length == 0 p>
(2)Product list(Paging):
–Parameter:pno page numberpageSize page size
-sql SELECT id,img_url,price,title FROM xz_product
LIMIT ?,?
? (pno-1)*pageSize
? pageSize
-sql SELECT count(id) FROM xz_product;
Math.ceil(20/ pageSize); Round up
(3) Shopping Cart:
(0)List SELECT id,name,price,title,count FROM xz_car t;
(1)Add
Parameter:pid commodity number price commodity price count quantity< /span>
–Query whether the current product is in the shopping cart< /span>
SELECT id FROM xz_cart WHERE pid = ?
–If the product already existsUpdate quantity
UPDATE xz_cart SET count =? WHERE id = ?
–If the product does not exist Add< /p>
INSERT INTO xz_cart VALUES(null,pid,price, count,now())
(2)Calculate the total
span>Scaffolding calculation attributes
(3)< span style="font-family: Song Ti;">Edit(the number of items in the shopping cart)
< p>Parameters:idShopping cart Itemid count quantity
sql :UPDATE xz_cart SET count =? WHERE id = ?
(4)Delete[multiple selection]
Parameter:uid Whose shopping cart id=1,2,3< /span>
string splicing1,2,3 span>
sql:DELETE FROM xz_cart WHERE id IN (1,2,3)
(5)Create an order:
–Parameters:uid Shopping cart Userid
–Query the data in the shopping cart< /span> SELECT id,uid,price FROM xz_cart;
– Add order form INSERT INTO xz_order VALUES(?,?….)
2.3:node.js < span style="font-family: Song Ti;">Non-blocking[Efficient and disorderly] If there are functions, strict order is required
sql1
< span style="font-size: 16px;">pool.query(sql1,(err,result)=>{
//sql1 Be sure to end the execution Result< /p>
sql2
pool.query(sql2, )
));
3:Xuezi Mall—News List p>
View yesterday’s project xampp node.js vue-cli< /p>
3.1:Modify the display when scaffolding startsHome Component
Default foothand path http://127.0.0.1:8080/#/
{path:’/’,component:HelloContainer},
Edit :When the scaffolding visit/ Let the browser automatically send the address/ Edit/Home
Function: Jump< /span>
{path:’/’,redirect:’/Home’}
{path:’/Home’,component:Home},
3.2: EditApp.vueComponents
4:Xuezi Mall–News list
4.1:Create button “Load more…” mint-ui
-import {Button…} from “mint-ui”
-Vue.component(Button.name,Button);
–
4.2:Create a filter Format Date Object Create a global filter
–Create filtermain.js
Vue.filter(Filter name,function(val){
–Create date objects based on parameters
–Year Month Day hourminute bell Second
–Return string YMD h:mi:s
});
< p>–Call filtercomponent template
< span style="font-size: 16px;"> {{item.ctime | filter name}}
4.3: click the button span> “Load more…” View next page span>
–Binding click events for loading more buttons< /span>
–Create function to load more{Next}< /span>
–I have a problem with:< span style="font-family: 宋体;">Display the content of the next page and cover the content of the previous page
span style=”font-family: 宋体;”>Want to save the content of the previous page
this.list = [];
this.list = result.data.data;
var rows = this.list.concat(result.data.data);
This.list = rows;
5:Xuezi Mall
span>–product list
5.1:Analysis inquiry form span>
–Query current page content span>
xz_laptop Product list
xz_laptop_pic ProductPicture List
product number product title product price Product image
Lid title price md
span>
(1)The query table is stored inFROM后
(2)Create an alias for each table
(3)Find which column of the two tables is related= <= >=
SELECT l. lid,l.title,l.price,p.md
FROM xz_laptop l,xz_laptop_pic p
WHERE l.lid = p. laptop_id
GROUP BY l.lid
LIMIT ?,?;
app.js
5.2:Scaffolding< /span>
–Create an empty component src/ components/goods/GoodList.vue
–Configure access path span> /GoodsList
–Test
–Set the layout
< p>Wrong adjustment/Add button /Add a click event
Common errors
(1) net::ER R_CONNECTION_RESET node.jsProgram error stops working
span style=”font-family: 宋体;”>Resolve:Viewn ode.js Console error message
(2)error in your SQL syntax
reason span>:sqlSyntax is wrong