2018-04-13 08:19:50 +00:00
|
|
|
<cn>
|
|
|
|
#### 照片墙
|
|
|
|
用户可以上传图片并在列表中显示缩略图。当上传照片数到达限制后,上传按钮消失。
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### Pictures Wall
|
|
|
|
After users upload picture, the thumbnail will be shown in list. The upload button will disappear when count meets limitation.
|
|
|
|
</us>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<template>
|
|
|
|
<div class="clearfix">
|
|
|
|
<a-upload
|
|
|
|
action="//jsonplaceholder.typicode.com/posts/"
|
|
|
|
listType="picture-card"
|
|
|
|
:fileList="fileList"
|
|
|
|
@preview="handlePreview"
|
|
|
|
@change="handleChange"
|
|
|
|
>
|
|
|
|
<div v-if="fileList.length < 3">
|
|
|
|
<a-icon type="plus" />
|
|
|
|
<div class="ant-upload-text">Upload</div>
|
|
|
|
</div>
|
|
|
|
</a-upload>
|
|
|
|
<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
|
2018-07-03 02:22:03 +00:00
|
|
|
<img alt="example" style="width: 100%" :src="previewImage" />
|
2018-04-13 08:19:50 +00:00
|
|
|
</a-modal>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
previewVisible: false,
|
|
|
|
previewImage: '',
|
|
|
|
fileList: [{
|
2018-09-05 13:28:54 +00:00
|
|
|
uid: '-1',
|
2018-04-13 08:19:50 +00:00
|
|
|
name: 'xxx.png',
|
|
|
|
status: 'done',
|
|
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
|
}],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2018-07-03 02:22:03 +00:00
|
|
|
handleCancel () {
|
2018-04-13 08:19:50 +00:00
|
|
|
this.previewVisible = false
|
|
|
|
},
|
2018-07-03 02:22:03 +00:00
|
|
|
handlePreview (file) {
|
2018-04-13 08:19:50 +00:00
|
|
|
this.previewImage = file.url || file.thumbUrl
|
|
|
|
this.previewVisible = true
|
|
|
|
},
|
2018-07-03 02:22:03 +00:00
|
|
|
handleChange ({ fileList }) {
|
2018-04-13 08:19:50 +00:00
|
|
|
this.fileList = fileList
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
2018-07-03 02:22:03 +00:00
|
|
|
<style>
|
2018-04-13 08:19:50 +00:00
|
|
|
/* you can make up upload button and sample style by using stylesheets */
|
|
|
|
.ant-upload-select-picture-card i {
|
|
|
|
font-size: 32px;
|
|
|
|
color: #999;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-upload-select-picture-card .ant-upload-text {
|
|
|
|
margin-top: 8px;
|
|
|
|
color: #666;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
|
|
|
|
|