Spring boot +spring security +oss+vue front-end and back-end separation

Project scenario:

Separate the front and back ends to upload pictures to oss


Problem Description

When submitting image data to the background, the security framework shows that you are not logged in


Cause Analysis:

When using element ui's upload image component, the default request does not have a token

Just add it to the default request header


solution:

1.在哪个data数据中定义一个对象 用来获取当前客户端的token
//给上传图片的请求头里添加客户端的token
//不然会出现未登录 上传图片失败
upheaders: {
    token: localStorage.getItem('token')
},
2.然后 给element ui的上传组件加上一个标签就好了
:headers="upheaders"
这样组件的默认的请求头也带token了

It is best to use the group method when multiple radio boxes are selected by default.

 <el-radio-group v-model="editCarForm.isrenting">
                            <el-radio :label='0'>not rented</el-radio>
                            <el-radio :label='1'>rented</ el-radio>
  </el-radio-group>

The dynamic variable editCarForm.isrenting will be compared with the number of the label, and the one that is equal will be selected by default.

Note: label must be added: to complete data binding

Guess you like

Origin blog.csdn.net/qq_55648724/article/details/128611314