<template>
	<view class="content">
		<view class="one">
			<upload :list="form.file" name="file" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
			<button @tap="toSubmit()">提交</button>
		</view>
	</view>
</template>

<script>
	import upload from "@/components/upload/index.vue";
	export default {
		components: {
			upload,
		},
		data() {
			return {
				form: {
					file: [],
				},
			};
		},
		onLoad() {},
		methods: {
			// 图片上传
			uplSuc(e) {
				const that = this;
				that.$set(that.form, `${e.name}`, [...that.form[e.name], e.data]);
			},
			// 图片删除
			uplDel(e) {
				const that = this;
				let data = that.form[e.name];
				let arr = data.filter((i, index) => index != e.data.index);
				that.$set(that.form, `${e.name}`, arr);
			},
			toSubmit(){
				console.log(this.form);
			}

		},
	};
</script>

<style lang="scss"></style>
