赞
踩
前端 api 接口模板:
import request from '@/utils/request'
export function getDetail(query) {
return request({
url: '/mytest/testdata/detail',
method: 'get',
params: query, // 注意是 params 参数
})
}
前端调用模块演示:
<script> import {getDetail} from "@/api/test/detail"; 省略内容... method:{ getdata(){ getDetail({id: this.$route.params.id}).then(response =>{ console.log("response data:", response) }) } } </script>
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import lombok.extern.log4j.Log4j2; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/mytest") @Log4j2 public class TestController extends BaseController { @GetMapping("/testdata/detail") public AjaxResult getDetailInfo(String id) { System.err.println("get detail id: " + id); return AjaxResult.success("调用接口成功"); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。