87,902
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>Title</title>
</head>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"> </script>
<body>
<div id="login">
{{message}}
</div>
</body>
<script type="text/javascript">
var vue=new Vue({
el:'#login',
data:{
message:'11111'
},
mounted(){
axios
.get('/hello')
.then(function (response){
this.message=response.data;
console.log(this.message);
} )
.catch(function (error){ // 请求失败处理
console.log(error);
});
}
})
</script>
</html>
明明获取到了新数据,但是message还是显示原来的
.then(response => {
// this.message=response.data;
//this.message
} )
.then(response => {
this.message=response.data;
//this.message
} )