ソースを参照

fix(uploader): ts declaration errors

richard1015 3 年 前
コミット
ff3520c2b9

+ 9 - 5
src/packages/__VUE/uploader/index.taro.vue

@@ -2,7 +2,7 @@
   <view :class="classes">
     <view class="nut-uploader__slot" v-if="$slots.default">
       <slot></slot>
-      <template v-if="maximum - fileList.length">
+      <template v-if="Number(maximum) - fileList.length">
         <nut-button class="nut-uploader__input" @click="chooseImage" />
       </template>
     </view>
@@ -61,9 +61,11 @@
     <view
       class="nut-uploader__upload"
       :class="[listType]"
-      v-if="listType == 'picture' && !$slots.default && maximum - fileList.length"
+      v-if="listType == 'picture' && !$slots.default && Number(maximum) - fileList.length"
     >
-      <nut-icon v-bind="$attrs" :size="uploadIconSize" color="#808080" :name="uploadIcon"></nut-icon>
+      <slot name="upload-icon">
+        <Photograph color="#808080" />
+      </slot>
       <nut-button class="nut-uploader__input" @click="chooseImage" />
     </view>
   </view>
@@ -80,10 +82,12 @@ import Button from '../button/index.taro.vue';
 const { componentName, create, translate } = createComponent('uploader');
 import Taro from '@tarojs/taro';
 import { isPromise } from '@/packages/utils/util';
+import { Photograph } from '@nutui/icons-vue';
 export default create({
   components: {
     [Progress.name]: Progress,
-    [Button.name]: Button
+    [Button.name]: Button,
+    Photograph
   },
   props: {
     name: { type: String, default: 'file' },
@@ -112,7 +116,7 @@ export default create({
     headers: { type: Object, default: {} },
     data: { type: Object, default: {} },
     uploadIcon: { type: String, default: 'photograph' },
-    uploadIconSize: { type: [String, Number], default: '' },
+    // uploadIconSize: { type: [String, Number], default: '' },
     xhrState: { type: [Number, String], default: 200 },
     multiple: { type: Boolean, default: true },
     disabled: { type: Boolean, default: false },

+ 9 - 6
src/packages/__VUE/uploader/index.vue

@@ -2,7 +2,7 @@
   <view :class="classes">
     <view class="nut-uploader__slot" v-if="$slots.default">
       <slot></slot>
-      <component :is="renderInput" @change="onChange" v-if="maximum - fileList.length"></component>
+      <component :is="renderInput" @change="onChange" v-if="Number(maximum) - fileList.length"></component>
     </view>
 
     <view class="nut-uploader__preview" :class="[listType]" v-for="(item, index) in fileList" :key="item.uid">
@@ -26,7 +26,7 @@
         <img
           class="nut-uploader__preview-img__c"
           @click="fileItemClick(item)"
-          v-if="item.type.includes('image') && item.url"
+          v-if="item?.type?.includes('image') && item.url"
           :src="item.url"
         />
         <view v-else class="nut-uploader__preview-img__file">
@@ -62,10 +62,11 @@
     <view
       class="nut-uploader__upload"
       :class="[listType]"
-      v-if="listType == 'picture' && !$slots.default && maximum - fileList.length"
+      v-if="listType == 'picture' && !$slots.default && Number(maximum) - fileList.length"
     >
-      <nut-icon v-bind="$attrs" :size="uploadIconSize" color="#808080" :name="uploadIcon"></nut-icon>
-
+      <slot name="upload-icon">
+        <Photograph color="#808080" />
+      </slot>
       <component :is="renderInput" @change="onChange"></component>
     </view>
   </view>
@@ -78,10 +79,12 @@ import { Uploader, UploadOptions } from './uploader';
 import { FileItem } from './type';
 import { funInterceptor, Interceptor } from '@/packages/utils/util';
 import Progress from '../progress/index.vue';
+import { Photograph } from '@nutui/icons-vue';
 const { componentName, create, translate } = createComponent('uploader');
 export default create({
   components: {
-    [Progress.name]: Progress
+    [Progress.name]: Progress,
+    Photograph
   },
   props: {
     name: { type: String, default: 'file' },