result.then(r => { this.localPagination = Object.assign({}, this.localPagination, { current: r.pageNo, // 这里修改当前分页字段 total: r.totalCount, // 这里修改总记录数字段 showSizeChanger: this.showSizeChanger, pageSize: (pagination && pagination.pageSize) || this.localPagination.pageSize // 这里修改总记录数当前页数字段 }) //r.data中的data修改为返回列表字段 if (r.data.length == 0 && this.localPagination.current != 1) { this.localPagination.current-- this.loadData() return } !r.totalCount && [‘auto‘, false].includes(this.showPagination) && (this.localPagination = false) this.localDataSource = r.data // 返回结果中的数组数据 this.localLoading = false });
columns: [ ... { title: ‘操作‘, dataIndex: ‘id,text‘, key: ‘id‘, scopedSlots: { customRender: ‘operation‘ } } 】
:pagination="{showTotal: total => `共${total}条`}"
<a-tag v-for="(tag, index) in Tags" :key="tag.id" :closable="tagCloseable" :afterClose="() => handleTagStatus(0,tag)" >{{ tag.name }} </a-tag>
this.Tags = this.Tags.filter(tag => tag.id !== removeTag.id)
this.form.validateFields([‘name‘], { force: true })
this.form.resetFields(`name`,‘‘)
this.form.resetFields(`name`,‘‘)
<a-upload :customRequest="upLoad"></a-upload>
upLoad (info) { let file = info.file; let param = new FormData(); //创建form对象 param.append(‘file‘,file);//通过append向form对象添加数据 console.log(param.get(‘file‘)); //FormData私有类对象访问不到,可以通过get判断值是否传进去 let config = { headers:{‘Content-Type‘:‘multipart/form-data‘} }; this.$http.post(url, param, config).then(res => { ... }) },
const service = axios.create({ baseURL: `${process.env.VUE_APP_BASEURL}/backend`, withCredentials: true, timeout: 6000 })
router.beforeEach((to, from, next) => { // 对403无权限的处理 if (to.path === ‘/403‘) { next() } else { if (roles) {//已登陆 next() } else { //获取用户信息,GetUserInfo逻辑如下: //status=403 && reject(res),返回包含status; //status=1005 && reject(res.data)返回重定向的URL; //status=1000 && resolve() store .dispatch(‘GetUserInfo‘) .then(res => { next() }) .catch((e) => { if (e.status) { next({ path: ‘/403‘ }) } else { //拼接URL跳去登陆页,登陆成功会重定向回当前页(login_redirect) const url = e.substring(0, e.lastIndexOf(‘redirect‘)) + ‘redirect=‘ + login_redirect window.location.href = url } }) } } })
service.interceptors.response.use((response) => { if (response.data.status === 1005){ //... 同上跳去登陆页 }else{ //为返回数据做统一处理 return response.data } }, err)
原文:https://www.cnblogs.com/jlliu/p/11165741.html