index.vue 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <upload :list="form.file" name="file" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
  5. <button @tap="toSubmit()">提交</button>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import upload from "@/components/upload/index.vue";
  11. export default {
  12. components: {
  13. upload,
  14. },
  15. data() {
  16. return {
  17. form: {
  18. file: [],
  19. },
  20. };
  21. },
  22. onLoad() {},
  23. methods: {
  24. // 图片上传
  25. uplSuc(e) {
  26. const that = this;
  27. that.$set(that.form, `${e.name}`, [...that.form[e.name], e.data]);
  28. },
  29. // 图片删除
  30. uplDel(e) {
  31. const that = this;
  32. let data = that.form[e.name];
  33. let arr = data.filter((i, index) => index != e.data.index);
  34. that.$set(that.form, `${e.name}`, arr);
  35. },
  36. toSubmit(){
  37. console.log(this.form);
  38. }
  39. },
  40. };
  41. </script>
  42. <style lang="scss"></style>