axios简单使用例子
import axios from 'axios' export default { name: 'Test', data(){ return{ msg:"Welcome" } }, mounted() { //get axios.get( "/api/qc/sfaa-t/Count" ).then(res =>{ console.log(res) }) //post axios.post("/api/qc/sfaa-t/postCount",{"code":"1234"} ).then(res =>{ console.log(res) }) }, methods:{ sendClickHandle(){ this.$emit("onEvent",this.msg) } } }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
@RequestMapping("/qc/sfaa-t") public class SfaaTController { @Resource private ISfaaTService sfaaTService ; @GetMapping("/Count") public Integer fun(){ return sfaaTService.getsfaaTCount(); } //required:该参数是否为必传项。默认是true //value:请求中传入参数的名称,如果不设置后台接口的value值,则会默认为该变量名。 //defaultValue:参数的默认值,如果请求中没有同名的参数时,该变量默认为此值。 @PostMapping("/postCount") public Integer fun2(@RequestParam(required = false ,value = "page" ,defaultValue = "0") String code){ return fun(); } }后台接口类
proxy
const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, //代理 devServer: { proxy: { '/api': { target: 'http://localhost:8090', changeOrigin: true, pathRewrite: { '^/api': '' } } } } })
标签:axios,return,res,代理,qc,api,proxy From: https://www.cnblogs.com/shuzhixia/p/17005638.html