首页 > 其他分享 >Axios

Axios

时间:2022-12-01 19:27:28浏览次数:45  
标签:info Axios resp str data app

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<script type="text/javascript" src="js/axios.min.js"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<title></title>
	</head>
	<body>
		<div id="app">
			{{info.message}} + {{info.code}}
			
			
		</div>
	</body>
	
	
	<script>
		var app = new Vue({
			el : "#app",
			data : {
				info : {}
			},
			
			methods : {
				
			},
			
			mounted() {
				//get请求
				axios
					.get("data.json",{
						params: {
							ID: 123
						}
					})
					.then(resp =>{
						//成功处理
						console.log(resp);
						this.info = resp.data
					})
					.catch(error =>{
						//错误处理
					})
					.then(function(){
						//一定执行
					})
				//Post
				axios({
					method: 'post',
					url: '',
					data: {
						
					}
				})
			}
			
		})
		
	</script>
</html>

数据来源

{
	"message" : "str",
	"code" : 100,
	"data" : [
		{
			"name" : "str",
			"id" : 1
		},
		{
			"name" : "str",
			"id" : 2
		}
	]
}

标签:info,Axios,resp,str,data,app
From: https://www.cnblogs.com/lwx11111/p/16942409.html

相关文章