想要实现一打开页面就加载函数的效果,只需要添加created就可以了
把需要执行的方法先在methods中声明,然后再created中调用
var user = new Vue({
el:"#user",
data: {
users:[],
},
//*********************************
created:function(){
this.findAll();
},
//*********************************
methods:{
findAll:function (){
var that=this;
axios.get("http://localhost:8080/user/findall").then(
function (response){
that.users=response.data;
},
function (err){
console.log(err)
}
)
},
}
})
推荐阅读:
vue.js:634 [Vue warn]: Property or method "userName" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See:
状态码:415,发送HTTP请求返回415状态码的解决办法
SpringBoot 整合 webapp时 访问404的解决办法
SpringCloud怎么调用多个服务的信息
Spring整合Mybatis
Controller之间的跳转
SpringCloud 加入 thymleaf前端页面的方法
Spring AOP的实现原理
This may be the result of an unspecified view, due to default view name generation
给idea添加thymleaf模板
Seek respect, not attention.