uniapp向后端 SpringBoot传值

文章描述了一个使用Vue的表示层处理用户点击删除按钮,通过发送POST请求到后端Controller的`delete`方法,实现商品ID的删除。后端通过SpringBoot的@PostMapping处理请求并调用数据库删除操作。
摘要由CSDN通过智能技术生成

表示层

<view class="sort-Header sort-table" v-for="(item,index) in sort" :key="index">

        <text class="occupy">{{item.message}}</text>
        <text class="sort-but" @click="deletes(item.id,index,item.num)">删除按钮</text>
        <!--         <text class="occupy">休闲零食</text>
        <text class="sort-but">删除按钮</text> -->
    </view>

方法

function deletes(id,index,num){
        console.log(id)
        if(num>0){
            new Feedback('先删此类下的商品','none').toast()
            return
        }
        uni.request({
            url: BASE_URL + '/echarts/delete',
            method:'POST',
            data:{
                "id":id
            },
            header:{'content-type':'application/x-www-form-urlencoded'},
            // dataType:JSON,
            success(res) {
                console.log(res)
                
            }
            
        })

Controller

@PostMapping("delete")
public Boolean delete(@RequestParam("id") String id){
System.out.println(id);
boolean b = dsLingShiMapperService.removeById(id);
return b;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值