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 @ 2022-04-26 01:16  勤快的懒羊羊  阅读(3609)  评论(0编辑  收藏  举报