1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
- <view class="notice">本Demo的下拉刷新: 添加新数据到列表顶部</view>
- <view class="news-li" v-for="news in dataList" :key="news.id">
- <view>{{news.title}}</view>
- <view class="new-content">{{news.content}}</view>
- </view>
- </mescroll-body>
- </template>
- <script>
- import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
- import {apiNewList} from "@/api/mock.js"
-
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- downOption: {
- auto: false
- },
- dataList: []
- }
- },
- methods: {
-
- downCallback() {
-
- apiNewList().then(data => {
-
- this.mescroll.endSuccess();
-
- this.dataList.unshift(data[0]);
- }).catch(()=>{
-
- this.mescroll.endErr();
- })
- },
-
- upCallback(page) {
-
- apiNewList(page.num, page.size).then(curPageData=>{
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.mescroll.endSuccess(curPageData.length);
-
-
- this.dataList=this.dataList.concat(curPageData);
- }).catch(()=>{
-
- this.mescroll.endErr();
- })
- }
- }
- }
- </script>
- <style>
-
- .notice{
- font-size: 30upx;
- padding: 40upx 0;
- border-bottom: 1upx solid #eee;
- text-align: center;
- }
-
- .news-li{
- font-size: 32upx;
- padding: 32upx;
- border-bottom: 1upx solid #eee;
- }
- .news-li .new-content{
- font-size: 28upx;
- margin-top: 10upx;
- margin-left: 20upx;
- color: #666;
- }
- </style>
|