<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟</title> <script src="js/vue.js"></script> <script src="js/vue-resource.min.js"></script> <link href="example.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="example"> <button id="but" >添加</button> <ul id="example1"> <li v-for="item in items"> {{ item.id }} {{ item.author }} </li> </ul> </div> <script> //在这里面写Vue.js代码 var example = new Vue({ el: '#example', data: { items: [ { id:'0',author:'我'} ] }, ready:function(){ this.$http.jsonp('1.json',{},{ headers:{ }, emulateJSON: true }).then(function(response){ alert('123'); },function(response){ }); } }) //---------------- </script> </body> </html> //浏览器无法弹出123
jsonp是跨域的,请求本地写它干嘛 this.$http.get()就行了,具体回调函数看着也有问题 没看你想请求什么数据..response参数也不用
必须在http或https协议下才能用AJAX,file协议下浏览器默认禁用AJAX