Commit 78b46fa61946fde4d0004b4c263633e794bb6b41

Authored by 梁灏
1 parent 109465d3

Scroll add local loading-text

examples/routers/scroll.vue
1 <template> 1 <template>
2 - <Scroll :on-reach-top="loadData" loading-text="L-o-a-d-i-n-g..."> 2 + <Scroll :on-reach-edge="loadData">
3 <section v-for="item in list"> 3 <section v-for="item in list">
4 <div class="city"> 4 <div class="city">
5 <p>{{ item }}</p> 5 <p>{{ item }}</p>
src/components/scroll/scroll.vue
@@ -9,13 +9,13 @@ @@ -9,13 +9,13 @@
9 ref="scrollContainer" 9 ref="scrollContainer"
10 > 10 >
11 <div :class="loaderClasses" :style="{paddingTop: wrapperPadding.paddingTop}" ref="toploader"> 11 <div :class="loaderClasses" :style="{paddingTop: wrapperPadding.paddingTop}" ref="toploader">
12 - <loader :text="loadingText" :active="showTopLoader"></loader> 12 + <loader :text="localeLoadingText" :active="showTopLoader"></loader>
13 </div> 13 </div>
14 <div :class="slotContainerClasses" ref="scrollContent"> 14 <div :class="slotContainerClasses" ref="scrollContent">
15 <slot></slot> 15 <slot></slot>
16 </div> 16 </div>
17 <div :class="loaderClasses" :style="{paddingBottom: wrapperPadding.paddingBottom}" ref="bottomLoader"> 17 <div :class="loaderClasses" :style="{paddingBottom: wrapperPadding.paddingBottom}" ref="bottomLoader">
18 - <loader :text="loadingText" :active="showBottomLoader"></loader> 18 + <loader :text="localeLoadingText" :active="showBottomLoader"></loader>
19 </div> 19 </div>
20 </div> 20 </div>
21 </div> 21 </div>
@@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
24 import throttle from 'lodash.throttle'; 24 import throttle from 'lodash.throttle';
25 import loader from './loading-component.vue'; 25 import loader from './loading-component.vue';
26 import { on, off } from '../../utils/dom'; 26 import { on, off } from '../../utils/dom';
  27 + import Locale from '../../mixins/locale';
27 28
28 const prefixCls = 'ivu-scroll'; 29 const prefixCls = 'ivu-scroll';
29 const dragConfig = { 30 const dragConfig = {
@@ -35,7 +36,7 @@ @@ -35,7 +36,7 @@
35 36
36 export default { 37 export default {
37 name: 'Scroll', 38 name: 'Scroll',
38 - mixins: [], 39 + mixins: [ Locale ],
39 components: {loader}, 40 components: {loader},
40 props: { 41 props: {
41 height: { 42 height: {
@@ -52,8 +53,7 @@ @@ -52,8 +53,7 @@
52 type: Function 53 type: Function
53 }, 54 },
54 loadingText: { 55 loadingText: {
55 - type: String,  
56 - default: '' 56 + type: String
57 } 57 }
58 }, 58 },
59 data() { 59 data() {
@@ -98,7 +98,14 @@ @@ -98,7 +98,14 @@
98 paddingTop: this.topRubberPadding + 'px', 98 paddingTop: this.topRubberPadding + 'px',
99 paddingBottom: this.bottomRubberPadding + 'px' 99 paddingBottom: this.bottomRubberPadding + 'px'
100 }; 100 };
101 - } 101 + },
  102 + localeLoadingText () {
  103 + if (this.loadingText === undefined) {
  104 + return this.t('i.select.loading');
  105 + } else {
  106 + return this.loadingText;
  107 + }
  108 + },
102 }, 109 },
103 methods: { 110 methods: {
104 // just to improve feeling of loading and avoid scroll trailing events fired by the browser 111 // just to improve feeling of loading and avoid scroll trailing events fired by the browser