Hang Summary and learn to do vue encountered in the project

1, the emergence of cross-domain problem (in the case have been set up cross-domain)

This problem looking for a long time. . . . Final Solution: Check back office and front-end coding format axios whether the transmission encoding format consistent with the past. There will be inconsistencies cross-domain problems. As for why do not understand, could be considered inconsistent with the browser's cross-domain coding is also possible that a bug in the browser bar.

DETAILED DESCRIPTION: qs call can install a dependency, then the request with prior qs.stringify () method of turn about the resending request, ok.

First, download qs: npm install qs 

Then introduced import qs from 'qs'

Set in the request interface look:

Code: Export the userLogin function (the params) { 
return-Service ({
Method: 'POST',
URL: '/ A / Login',
Data: qs.stringify (the params), mainly // This step is important!
}) The then. ((RES) => {} return res.data). the catch ((ERR) => {the console.log (ERR)})
}

2, vue bind multiple routes to the same components, resulting created only once, that is once the page loads after successful can not change, no matter how it is triggered only display data routing jump page first loaded.

Effect: Click the left side of the tree nodes to achieve the right side of the page jump

 

After checking the data, the reason is: the vue and the life cycle of a relationship, this happens because the page is loaded after the success of his most hook function (such as mounted, computed ...) will not trigger again, resulting in page did not feel it possible to jump.

Solution: In view of this situation, in fact, does not require page switching, data only need to change the page just fine. Monitor routing address of the page change, when the change of address, you reload the data.

Specific code:

Watch: { 
'$ route.path': function (to, from) {
this.initInfo (); // call the appropriate methods
}
}

3, el-tree control, move the mouse hand tree node, the hand and the mouse display does not correspond to the node.

The reason: styling problems, through f12 debugging found that height is too high a bar tree node, so that the other nodes are covered, so this node height is too high, the span is too large, so the mouse hand and node location will biased.

Solution: Modify the height of each tree node.

4, el-tree controls, how to set the background color of the selected tree node

Solution: plus highlight-current

In the style settings:

 

 

 

Guess you like

Origin www.cnblogs.com/jennydtt/p/11127745.html