get访问
this.$http.get(
'http://192.168.xxx.xxx:8080/路径'
).then(res => {
console.log('连接成功!')
console.log(res)
}).catch(error => {
console.log('连接失败!')
console.log(error)
})
axios连接
$.ajax({
// this.$http.ajax({
type: 'get',
async: true,
// 异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
url: 'http://192.168.xxx.xxx:8080/端口',
// 请求发送到TestServlet处
data: {},
dataType: 'json',
// 返回数据形式为json
success: function (result) {
// 请求成功时执行该函数内容,result即为服务器返回的json对象
console.log('请求成功')
}
},
error: function (errorMsg) {
// 请求失败时执行该函数
alert('图表请求数据失败!')
}
})