<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> <script src="vue-resource.js"></script> </head> <body> <div id="app"> <button @click = "postdata">请求</button> </div> </body> <script> new Vue({ el: '#app', methods:{ postdata:function(){ // 1请求的url var url = 'http://vueapi.ittun.com/api/addprodlist'; //2.0 利用vue-resource发出ajax的get请求 this.$http.post(url,{name:'小狮子'},{emulateJSON:true})//发出请求 .then(function(response){ alert(response.body.message); }); } } }); </script> </html>
Ajax的post请求
最新推荐文章于 2024-02-23 11:46:43 发布