<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 () // method call }, methods: { getfrients: function () { var that = this if (that.token == null) { window.location.href = "loginRegister.html"; } The else { // Loading var index = layer.load ( 2 , { Shade: [ 0.1 , ' #fff ' ] // 0.1 transparency of the white background }); $.ajax({ of the type: " POST " , // submission url: the URL of + " index.php / Api / Myfriend / index " , // path dataType: ' json ' , data: { token: that.token, page: 1 }, Success: function (RES) { // return data corresponding processing according to the result of IF (res.code == . 1 ) { that.airdrop = res.data.airdrop; that.friend_number = res.data.friend_number that.friendLists = res.data.friend } } }) } } } }); </script>