VUE demo
<script>
var vm = new Vue({
el: '#box',
data: {
sites: [],
page: 1,
airdrop: 0,
friend_number: 0,
friendLists: ''
},
created: function () {
var that = this
that.token = localStorage.getItem('token')
console.log(that.token)
that.getfrients()//方法调用
},
methods: {
getfrients: function () {
var that = this
if (that.token == null) {
window.location.href = "loginRegister.html";
} else {
// 加载中
var index = layer.load(2, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
$.ajax({
type: "POST", //提交方式
url: URL + "index.php/Api/Myfriend/index", //路径
dataType: 'json',
data: {
token: that.token,
page: 1
},
success: function (res) { //返回数据根据结果进行相应的处理
if (res.code == 1) {
that.airdrop = res.data.airdrop;
that.friend_number = res.data.friend_number
that.friendLists = res.data.friend
}
}
})
}
}
}
});
</script>

浙公网安备 33010602011771号