[Doc] List: update demo & document (#2573)

This commit is contained in:
neverland
2019-01-20 17:12:34 +08:00
committed by GitHub
parent c43edf987f
commit 58b54b1970
5 changed files with 177 additions and 97 deletions
+37 -6
View File
@@ -16,9 +16,7 @@ Vue.use(List);
<van-list
v-model="loading"
:finished="finished"
:error.sync="error"
finished-text="Finished"
error-text="Request failed. Click to reload..."
@load="onLoad"
>
<van-cell
@@ -36,7 +34,6 @@ export default {
list: [],
loading: false,
finished: false
error: false
};
},
@@ -48,9 +45,6 @@ export default {
}
this.loading = false;
// when error loaded:
// this.error = true;
if (this.list.length >= 40) {
this.finished = true;
}
@@ -60,6 +54,43 @@ export default {
}
```
### Error Info
```html
<van-list
v-model="loading"
:error.sync="error"
error-text="Request failed. Click to reload"
@load="onLoad"
>
<van-cell
v-for="item in list"
:key="item"
:title="item"
/>
</van-list>
```
```js
export default {
data() {
return {
list: [],
error: false,
loading: false
};
},
methods: {
onLoad() {
fetchSomeThing().catch(() => {
this.error = true;
})
}
}
}
```
### API
| Attribute | Description | Type | Default |