zhangzengfei
2022-11-17 82d8cf2628b7d8f741b53053855b9cfed97b13c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
  <label class="uploader-btn" ref="btn" v-show="support">
    <slot></slot>
  </label>
</template>
 
<script>
import { uploaderMixin, supportMixin } from "./common/mixins";
 
const COMPONENT_NAME = "uploader-btn";
 
export default {
  name: COMPONENT_NAME,
  mixins: [uploaderMixin, supportMixin],
  props: {
    directory: {
      type: Boolean,
      default: false,
    },
    single: {
      type: Boolean,
      default: false,
    },
    attrs: {
      type: Object,
      default() {
        return {};
      },
    },
    sourceType: {
      type: Number,
    },
  },
 
  mounted() {
    this.$nextTick(() => {
      let props = { accept: "" };
      if (this.sourceType == 1) {
        props.accept = ".mp4";
      } else if (this.sourceType == 2) {
        props.accept = ".jpg,.jpeg,.png";
      }
      this.uploader.uploader.assignBrowse(
        this.$refs.btn,
        this.directory,
        this.single,
        props
      );
    });
  },
};
</script>
 
<style>
.uploader-btn {
  display: inline-block;
  position: relative;
  padding: 4px 8px;
  font-size: 100%;
  line-height: 1.4;
  color: #666;
  border: 1px solid #666;
  cursor: pointer;
  border-radius: 2px;
  background: none;
  outline: none;
}
.uploader-btn:hover {
  /* background-color: rgba(0, 0, 0, 0.08); */
}
</style>