赞
踩
上传导入时,接口需要携带 token ,组件用的是 el-upload ,我们把 token 放到 headers 里即可
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:data="importData"
:show-file-list="false"
:on-success="handleSuccess"
:headers="headers"
>
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
<script> export default { data() { return { headers:{}, importData:{imporType: 1}, token:"" }, mouted() { this.token = localStorage.getItem("token") this.headers = {token: this.token} } methods: { handleSuccess(response){ if(response.responseCode == 0) { this.$message.success(response.responseMsg) } else { this.$message.error(response.responseMsg) } } } } </script>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。