tongshangming пре 2 година
родитељ
комит
a8c103e99a
2 измењених фајлова са 13 додато и 1 уклоњено
  1. 3 0
      src/components/form/ElImageUpload.vue
  2. 10 1
      src/views/form/Basic.vue

+ 3 - 0
src/components/form/ElImageUpload.vue

@@ -125,6 +125,9 @@ if (props.item) {
         </span>
       </span>
     </template>
+    <template #[slot.name]="slotProps" v-for="slot in item?.slots" :key="slot.alias">
+      <slot :name="slot.alias" v-bind="slotProps"></slot>
+    </template>
   </el-upload>
   <el-image-viewer v-if="showViewer" :url-list="previewList" :initial-index="previewIndex" @close="closeViewer" />
 </template>

+ 10 - 1
src/views/form/Basic.vue

@@ -245,7 +245,13 @@ const formConfig = reactive<BasicForm>({
       label: '图片',
       value: [],
       name: 'image',
-      type: 'image-upload'
+      type: 'image-upload',
+      slots: [
+        {
+          name: 'tip',
+          alias: 'tip'
+        }
+      ]
     },
     {
       label: '文件',
@@ -335,6 +341,9 @@ const handleInputConfirm = () => {
         <template #file>
           <el-button type="primary">上传文件</el-button>
         </template>
+        <template #tip>
+          <div><el-text>请上传750*450px 的图片</el-text></div>
+        </template>
 
         <template #password>
           <el-input type="password" name="password" v-model="formData.password" placeholder="请输入密码"></el-input>