Summary of Vue + Gin issues
Question 1: After triggering the dialog of Element UI in Vue, the page turns gray
Solution:
Add the append-to-body attribute to the el-dialog tag.
Question 2: After Vue is deployed on Nginx, access to the backend interface 404
The forwarding rules set in Nginx are as follows:
location /api {
~~~~ ~~~~ proxy_pass http://localhost:8081/;
}
The output information of the backend:
Solution:
Modify the forwarding rules as follows:
location /api/ {
~~~~ ~~~~ proxy_pass http://localhost:8081/;
}
Question 3: There is an error in the use of axios, showing undefined
reason:
Forgot to introduce axios in vue component.
Solution:
Axios usage process:
① Call the command in the console to install axios:
② In main.js:
③ In the vue component:
Question 4: The console reports an error, vue-cli-service is not an internal or external command...
reason:
Accidentally deleted node_modules folder.
Solution:
npm install
npm run serve
Question 5: After npm run serve starts the project, the page is blank
reason:
Forgot to add the App tag in index.html.
Solution:
Question 6: How to introduce external js in vue
method:
Question 7: How to realize local routing jump
method:
① In index.js, the parent route adds a child route (the path of the child route does not contain /): the
form specified in components is "name: component"
, where the router-view also has the name attribute, so that the two names are the same, so that Bind a component to a specific router-view.
② The name specified in the router-view tag is the name of the sub-route
③ Trigger routing jump in event function
Question 8: How to convert datetime type fields read from MySQL to standard time format
method:
as xxx cannot be omitted, otherwise the value cannot be successfully assigned to the corresponding field in the structure.
Question 9: Vue reads the Json data returned by Gin, but the console print is empty
reason:
When Vue reads the data returned by the backend, the Json field name used is wrong.
Solution:
After the data is serialized, the corresponding field name is set in the tag. When Vue reads the data returned by the backend, it must use the tag corresponding to the structure instead of the structure field name or database field name.
Question 10: How does gorm perform complex update operations
describe:
The new value obtained by operating on the basis of the original value is used as the updated value.
method:
Question 11: Gorm reports an error: WHERE conditions required
reason:
SQL operations through gorm must specify where conditions, even for full table operations.
Solution:
Question 12: Using the date time picker of Element UI, how to set the standard time format and eliminate the 8-hour error?
method:
Set value-format="yyyy-MM-dd HH:mm:ss"
Question 13: Every time you open a new terminal, you need to execute source /etc/profile to make the environment variables take effect
method one:
Add a sentence of source /etc/profile in ~/.bashrc, and then execute source ~/.bashrc once to make the file take effect.
Method Two:
Directly write the configuration statement in ~/.bashrc, and then execute source ~/.bashrc once to make the file take effect.
Reference source: https://www.cnblogs.com/hwh000/p/13683368.html