原因:在 then的內部不能使用Vue的實例化的this, 因為在內部 this 沒有被綁定
解決方法有:
(1)用ES6箭頭函數,箭頭方法可以和父方法共享變量

(2)在請求ajax外面定義一下 var that=this
new Vue({
el: "#app",
data: {
sites: [],
},
created: function () {
//為了在內部函數能使用外部函數的this對象,要給它賦值了一個名叫self的變量。
var self = this;
$.ajax({
url: 'http://localhost:8080/student/json',
type: 'get',
dataType: 'json'
}).then(function (res) {
//把從json獲取的數據賦值給數組
self.sites=res;
console.log(getQueryVariable("page"))
console.log(res.length)
}).fail(function () {
console.log('失敗');
})
}
})
