About cli packaging BUG server to appear (style confusion, path error) Solution

Blog for a long time did not come to the park, today to give us two hard goods bug, the front end of Daniel might not think is valid, but did not come across this problem for a small rookie is still very good for me

1, when the build server to appear npm run path error solution

①, local testing without any problems on the packaging line, the entire error, a bug

Solution: Create a vue.config.js file inside the src folder at the same level directory

In vue.config.js the base path rewritten package for the current directory

 

②, after repackaging upload server, found that access is not being given, but the resources (such as index.html, index.css, xxx.js) also reported 304,404,401 requested these problems, the entire page is a black and white no own development stuff

  Solution: After a review of various data to conclude that the issue should be loaded mode of routing, since different vue-router mode, the server can not identify the cause, the solution is to change the access mode router in router.js in.

  We can see router.js inside mode is history 

 

Only the mode of "history" was changed to "hash" is OK again npm run build uploaded to the server on OK effective pro-test oh ~

 

2, uploaded to the server path no problem, but we found css styles bewildered
Solutions looks different is the style issue is packed when the order has the problem, there are some styles we are not in force, there are some patterns are covered. This time we can consider the following methods.

 ①, main.js style introduction sequence problem

  Sometimes we find patterns in the assembly is not in force, may have been a third-party component style covers, router on the last introduced, it can be achieved after the third-party component style rendering style.

  ②, a range style <style scoped>

    <Style scoped> H5 is a new feature, which limits the style applies only to the current component, to avoid the interference pattern between components.

 

 

 

Well share on here today friends ~ ~ ~ hope to the front end of the long road to provide a little bit of help if you do have any questions, you can contact me qq: 2407488005

Guess you like

Origin www.cnblogs.com/10ve/p/11354162.html