首先看看原始碼如下:
<script>
var jsonpfej4g9k4zv111;
function _jsonpfej4g9k4zv111(data){
jsonpfej4g9k4zv111 = data;
}
</script>
<script src="http://localhost/api.ashx?type=defalut&callback=_jsonpfej4g9k4zv111"></script>
<script>
console.log(jsonpfej4g9k4zv111);
</script>複製程式碼
接下來, 看Vue.jsonp跨域, 同理:
<script>
var vm = new Vue({
el: '#app'
,data: {
message: 'Hello World'
}
,mounted() {
console.log('mounted');
this.$http.jsonp('http://localhost:59486/api.ashx?type=defalut')
.then(function(result){
console.log('jsonp data', result.body);
});
}
});
</script>複製程式碼
接下來,你怎麼看...