为了账号安全,请及时绑定邮箱和手机立即绑定

Vue.js2.x版本,get和jsonp都无法获得数据不

Vue.js2.x版本,get和jsonp都无法获得数据不

EugenioCode 2017-04-16 14:42:02
get请求代码如下:<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>vue入门</title>     <script src="vue.js"></script>     <script src="vue-resource.js"></script>     <script>         window.onload =  function () {             new Vue({                 el:'#box',                 data:{                 },                 methods:{                     get:function () {                         this.$http.get('./get.php',{a:2,b:1}).then(function (res) {                             alert(res.data)                         },function (res) {                             alert(res.status);                         })                     }                 }             })         }     </script> </head> <body> <div id="box">     <input type="button" value="获取" @click="get()"> </div> </body> </html>php代码如下:<?php $a = $_GET["a"]; $b = $_GET["b"]; echo $a+$b;jsonp函数如下:jsonp:function () {     this.$http.jsonp('https://sug.so.360.cn/suggest',{         word:"a",     },{emulateJSON:true}).then(function (res) {         alert(res.data.s);     },function (res) {         alert(res.status);     }) }两个都无法拿到数据
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 2530 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信