第一次打开的时候是没有问题id,第二次(切换路由到其他页面,再回来就没用了);
在生命周期方法created,updated mounted中都试过了,还是无效,啊 气疯了!求帮忙解决啊!!!
<template>
<div>
<div class="mui-content">
<!--下拉刷新容器-->
<div id="lists" class="mui-content mui-scroll-wrapper" style="margin-bottom: 4rem;">
<div class="mui-scroll">
<!--数据列表-->
<ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell" v-for="(topic,index) of topics"><a class="mui-navigate-right">Item {{index}}</a></li>
</ul>
</div>
</div>
<nav-components></nav-components>
</div>
</div>
</template>
<script scoped>
import navComponents from './nav.vue'
export default {
components: {navComponents},
name: "index",
data() {
return {
topics: [],
}
},
methods: {
pulldownRefresh: function () {
alert();
},
pullupRefresh: function () {
var count = 0;
var that = this;
setTimeout(function() {
that.topics.push({
"id": 14,
"content": "xxxxx。",
"clicl_number": 0,
"support_number": 0,
"create_time": "2018年07月23日 17:02:04",
"user": {
"nickname": "测试账户002",
"face_url": "http://thinkpjax.cn/xxxxxxx.jpeg"
}
});
}, 1500);
}
},
mounted: function () {
var that = this;
mui("#lists").scroll({
deceleration: 0.0006,
scrollY: true, //是否竖向滚动
bounce: true, ///是否启用回弹
});
},
created(){
mui.init({
pullRefresh: {
container: '#lists',
up: {//上拉加载
auto:true,//可选,默认false.自动上拉加载一次
contentrefresh: '正在加载...',
contentnomore:'没有更多数据了',//可选,请求完毕若没有更多数据时显示的提醒内容;
callback: this.pullupRefresh
}
}
});
},
}
</script>
你的 router-view 是不是用 keep-alive 包裹了? 这样子的话
created
和mounted
在路由在再次切进来时是不会触发的.