hanbaoshan
2020-10-27 da98d2a8a686cde09b20345e4a2b55a85410fde4
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
<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 {}
      }
    }
  },
  watch:{
    attrs:{
      handler(n,o){
        debugger
        this.$nextTick(()=>{
          this.uploader.uploader.assignBrowse(this.$refs.btn, this.directory, this.single, n)
        })
      },
      deep: true
    }
  },
  mounted() {
    this.$nextTick(() => {
      console.log('attrs',this.attrs)
      this.uploader.uploader.assignBrowse(this.$refs.btn, this.directory, this.single, this.attrs)
    })
  }
}
</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>