FileUploader.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="c-input">
  3. <label>
  4. <span>{{iconMap.upload}} 点击选取文件上传</span>
  5. <input
  6. type="file"
  7. :placeholder="placeholder"
  8. :value="value"
  9. @input="$emit('input', $event.target.value)"
  10. />
  11. </label>
  12. </div>
  13. </template>
  14. <script>
  15. import iconMap from '@/utils/icon-map'
  16. export default {
  17. model: {
  18. prop: 'value',
  19. event: 'input'
  20. },
  21. props: {
  22. value: String,
  23. placeholder: String
  24. },
  25. data () {
  26. return {
  27. iconMap: iconMap
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. @import '~@/style/theme.scss';
  34. .c-input {
  35. position: relative;
  36. display: inline-flex;
  37. align-items: center;
  38. overflow: hidden;
  39. box-sizing: border-box;
  40. font-size: 16px;
  41. font-weight: bold;
  42. color: #3a4a5a;
  43. background: $input-background-color;
  44. border-radius: 8px;
  45. border: none;
  46. outline: none;
  47. width: 100%;
  48. height: 48px;
  49. line-height: 40px;
  50. padding: 0 0 0 12px;
  51. transition: .2s;
  52. & span {
  53. font-family: 'iconfont', sans-serif;
  54. display: block;
  55. vertical-align: middle;
  56. color: #5a6a7a;
  57. }
  58. &:hover {
  59. background: darken($input-background-color, 5);
  60. }
  61. }
  62. input {
  63. position: absolute;
  64. left: 0;
  65. top: 0;
  66. padding: 20px 0;
  67. width: 100%;
  68. opacity: 0;
  69. }
  70. </style>