zoukankan      html  css  js  c++  java
  • vue-resource请求,类似ajax

    <template>
    	<div>
    		<div>vue-resource请求,类似ajax</div>
    		<div>----------------------------</div>
    	</div>
    </template>
    <script>
    	export default{
    		data(){
    			return{
    
    			}
    		},
    		mounted(){
    			//get请求   '/someUrl' 是后台地址的数据接口如:someUrl.php 等等
    			this.$http.get('/someUrl').then(response => {  //获取响应数据
    				// get body data
    				console.log(response.body);   //输出响应数据
    		    }, response => {
    		    	//error callback
    		    });
    
    		    //post请求     '/someUrl' 是后台地址的数据接口如:someUrl.php 等等
    		    // {foo: 'bar'}  给后台发送一些数据
    	    	this.$http.post('/someUrl', {foo: 'bar'}).then(response => {  //获取响应数据
    	    		// get body data
    	    		console.log(response.body);   //输出响应数据
    	        }, response => {
    	        	//error callback  请求失败执行的回调函数
    	        });
    
    
        	    //get请求     '/someUrl' 是后台地址的数据接口如:someUrl.php 等等
        	    // {foo: 'bar'}  给后台发送一些数据
            	this.$http.get('/someUrl', {params: {foo: 'bar'}, headers:{'X-Custom': '...'}} ).then(response => {  //获取响应数据
            		// success callback  请求成功的回调函数
                }, response => {
                	//error callback  请求失败的回调函数
                });
    		}
    	}
    </script>
    

      

  • 相关阅读:
    POJ 2155 Matrix
    Codeforces 626D Jerry's Protest 「数学组合」「数学概率」
    Codeforces 626E Simple Skewness 「数学」「二分」
    Codeforces 633D
    Codeforces 631C
    二分查找
    CodeForces 617C【序枚举】
    HDU 4405 【概率dp】
    ZOJ 3329 【概率DP】
    POJ 2096 【期望DP】
  • 原文地址:https://www.cnblogs.com/Knowledge-is-infinite/p/12207445.html
Copyright © 2011-2022 走看看