vue初始化页面加载数据

复制代码
 1 new Vue({
 2     el: '#main',
 3     data: {
 4         selectRepositoryOfTopInputParam: []//初始化页面,展示前10条内容
 5     },
 6     
 7     beforeCreate: function () { 
 8         //页面初始化
 9         this.$nextTick(() => {
10             this.InitData();
11         });
12     },
13     
14     methods: {
15         //页面初始化
16         InitData() {
17             const _this = this;
18             _this.selectRepositoryOfTopInputParam = true;//页面初始化显示前10条
19             axios.get('http://localhost:8080/selectRepositoryOfTopInputParam', {params: {displayItems: 10}}).then(function (response) {
20                 console.log(response);
21                 if (response.status === 200) {
22                     _this.selectRepositoryOfTopInputParam = response.data;
23                 }
24             }).catch(function (err) {
25                 console.log(err);
26                 _this.$message.error(err.toString());
27             });
28         }
29     },
30     beforeDestroy() {
31        
32     }
33 })
复制代码

 

posted @   勤快的懒羊羊  阅读(3663)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示