Summary of Vue + Gin issues (continuously updated)

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.
insert image description here

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:

insert image description here

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:
insert image description here

② In main.js:
insert image description here

③ In the vue component:
insert image description here


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:

insert image description here


Question 6: How to introduce external js in vue

method:

insert image description here

insert image description here

insert image description here


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.
insert image description here

② The name specified in the router-view tag is the name of the sub-route
insert image description here

③ Trigger routing jump in event function
insert image description here

Question 8: How to convert datetime type fields read from MySQL to standard time format

method:

insert image description here
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.
insert image description here


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:

insert image description here

Question 11: Gorm reports an error: WHERE conditions required

reason:

SQL operations through gorm must specify where conditions, even for full table operations.

Solution:

insert image description here


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"
insert image description here


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

Guess you like

Origin blog.csdn.net/weixin_46878177/article/details/128565196