一、删除购物车数据api
//删除购物车
export function deleteShopCar( params,token ){
return request({
url:'/api/shopcar/deleteShopCar',
params,
headers:{
token
}
})
}
二、添加删除事件
<li class="order-item delete" @click='del(item.id)'>
<a href="javascript:;">
<i class="el-icon-delete"></i>
<span class="deletd-text">删除</span>
</a>
</li>
//element
import { ElMessageBox } from 'element-plus';
import { ElMessage } from 'element-plus';
//删除购物车数据
const del = ( id )=>{
ElMessageBox.confirm('确定删除该课程吗?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createToken().then(res=>{
let token = res.data.token;
deleteShopCar({
id
},token)
})
ElMessage.success({
message: '删除成功!'
});
}).catch(() => {
ElMessage.info({
message: '已取消删除'
});
});
}
评论()