Browse Source

Merge branch 'v3-dev' of https://github.com/jdf2e/nutui into v3-dev

guoxiaoxiao8 5 years ago
parent
commit
65e130be2b

BIN
src/assets/img/img-clear.png


+ 4 - 0
src/packages/address/address.scss

@@ -1,4 +1,8 @@
 .nut-address {
+	ul{
+		padding: 0;
+		margin: 0;
+	}
 	.title {
 		display: flex;
 		justify-content: space-between;

+ 1 - 1
src/packages/badge/badge.scss

@@ -27,7 +27,7 @@
 		min-width: 0;
 		padding: 0;
 		border-radius: 50%;
-		background: $primary-color;
+		background: $primary-color-jd-red;
 	}
 
 	.single-val {

+ 5 - 1
src/packages/badge/demo.vue

@@ -40,7 +40,11 @@ export default {
 
 <style lang="scss" scoped>
 .item {
-	margin: 16px 26px 10px 10px;
+  margin: 16px 26px 10px 10px;
+  line-height: 15px;
+  font-family: PingFangSC-Regular;
+  font-size: 15px;
+  color: #646464;
 }
 
 .demo-w {

+ 1 - 1
src/packages/card/card.vue

@@ -85,7 +85,7 @@ export default {
       this.$emit(event);
     },
     headerClickHandler() {
-      this.$emit('switchClick');
+      this.$emit('switch-click');
     }
   }
 };

+ 11 - 6
src/packages/card/demo.vue

@@ -1,9 +1,9 @@
 <template>
-  <div class="demo-list">
+  <div class="demo-list card-list">
     <h4>基础样式</h4>
     <nut-card
       title="这里是默认卡片内容"
-      :footerButtons="footerButtons"
+      :footer-buttons="footerButtons"
       @click1="clickHandler1"
       @click2="clickHandler2"
     ></nut-card>
@@ -15,19 +15,19 @@
     <nut-card
       title="卡片标题"
       content="这里是卡片内容区域"
-      :footerButtons="footerButtons"
+      :footer-buttons="footerButtons"
       @click1="clickHandler1"
       @click2="clickHandler2"
     ></nut-card>
 
     <h4>可展开/收起的卡片</h4>
-    <nut-card title="卡片标题" content="这里是卡片内容区域" openIcon :isOpen="isOpen"  @switchClick="switchClick"></nut-card>
+    <nut-card title="卡片标题" content="这里是卡片内容区域" open-icon :is-open="isOpen"  @switch-click="switchClick"></nut-card>
 
     <h4>通栏卡片</h4>
-    <nut-card title="卡片标题" content="这里是卡片内容区域" isFull></nut-card>
+    <nut-card title="卡片标题" content="这里是卡片内容区域" is-full></nut-card>
 
     <h4>通过Slot插槽分发内容</h4>
-    <nut-card hasContent hasFooter>
+    <nut-card has-content has-footer>
       <div slot="title" class="card-title">
         <div class="right">我是标题</div>
         <div class="left">一小时</div>
@@ -70,6 +70,11 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+.card-list{
+  h4{
+    padding: 0 15px;
+  }
+}
 .card-title {
   display: flex;
   justify-content: space-between;

+ 11 - 11
src/packages/card/doc.md

@@ -8,7 +8,7 @@
 ```html
 <nut-card
   title="这里是默认卡片内容"
-  :footerButtons="footerButtons"
+  :footer-buttons="footerButtons"
   @click1="clickHandler1"
   @click2="clickHandler2"
 ></nut-card>
@@ -26,7 +26,7 @@
 <nut-card
   title="卡片标题"
   content="这里是卡片内容区域"
-  :footerButtons="footerButtons"
+  :footer-buttons="footerButtons"
   @click1="clickHandler1"
   @click2="clickHandler2"
 ></nut-card>
@@ -36,19 +36,19 @@
 可展开/收起的卡片
 
 ```html
-<nut-card title="卡片标题" content="这里是卡片内容区域" openIcon :isOpen="isOpen"  @switchClick="switchClick"></nut-card>
+<nut-card title="卡片标题" content="这里是卡片内容区域" open-icon :is-open="isOpen"  @switch-click="switchClick"></nut-card>
 ```
 
 通栏卡片
 
 ```html
-<nut-card title="卡片标题" content="这里是卡片内容区域" isFull></nut-card>
+<nut-card title="卡片标题" content="这里是卡片内容区域" is-full></nut-card>
 ```
 ## 自定义内容
 Card组件提供了多个插槽,可以灵活地自定义内容
 
 ```html
-<nut-card hasContent hasFooter>
+<nut-card has-content has-footer>
   <div slot="title" class="card-title">
     <div class="right">我是标题</div>
     <div class="left">一小时</div>
@@ -98,10 +98,10 @@ export default {
 | 字段    | 说明                                  | 类型   | 默认值                                                   |
 |---------|---------------------------------------|--------|----------------------------------------------------------|
 | title     | 标题 | String | '' |
-| openIcon  | 展开收起图标是否展示 | Boolean | false |
+| open-icon  | 展开收起图标是否展示 | Boolean | false |
 | content  | 内容 | String  | '' |
-| isOpen  | 是否展开卡片内容 | Boolean  | true |
-| footerButtons  | 底部按钮 | Array  | [] |
-| isFull  | 是否为通栏卡片 | Boolean  | false |
-| hasContent  | 使用slot自定义content内容 | Boolean  | false |
-| hasFooter  | 使用slot自定义底部按钮 | Boolean  | false |
+| is-open  | 是否展开卡片内容 | Boolean  | true |
+| footer-buttons  | 底部按钮 | Array  | [] |
+| is-full  | 是否为通栏卡片 | Boolean  | false |
+| has-content  | 使用slot自定义content内容 | Boolean  | false |
+| has-footer  | 使用slot自定义底部按钮 | Boolean  | false |

+ 13 - 4
src/packages/icon/icon.vue

@@ -61,11 +61,20 @@ export default {
       this.icon = this.url;
       this.type = 'self';
     } else {
-      if (types.indexOf(this.type) === -1) {
-        console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
-      } else {
-        this.icon = require('../../assets/svg/' + this.type + '.svg');
+
+      // if (types.indexOf(this.type) === -1) {
+      //   console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
+      // } else {
+      //   this.icon = require('../../assets/svg/' + this.type + '.svg');
+      // }
+
+      try {
+          this.icon = require('../../assets/svg/' + this.type + '.svg')
+      }
+      catch(err) {
+          console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
       }
+      
     }
   }
 };

File diff suppressed because it is too large
+ 83 - 73
src/packages/leftslip/demo.vue


+ 42 - 20
src/packages/leftslip/doc.md

@@ -58,40 +58,42 @@ export default {
 ```
 
 
-### 列表
+### 消息列表
 
 ```html
-<div class="address-list">
-    <nut-leftslip v-for="(item, index) in list" :key="item.id" ref="leftslip" class="addr-item" >
-        <div slot="slip-main" class="slip-main addr-main">
-          <div class="addr">
-            <p class="name-mobile">{{ item.tel } }</p>
-            <p class="full-addr">{{ item.addr } }</p>
-          </div>
-          <a class="addr-edit" href="javascript:void(0)"></a>
+<div class="cell-box">
+    <nut-leftslip v-for="(item, index) in list" :key="item.id" ref="leftslip">
+        <div slot="slip-main" class="slip-main">
+          <nut-cell class="cell-item" :title="item.title" :sub-title="item.subTitle">
+            <div slot="avatar"><nut-avatar sizeNum="60" :bg-image="require('../../assets/img/cell-avatar.jpeg')" bg-icon></nut-avatar></div>
+            <div slot="desc">
+              <p class="timer">{{item.time}}</p>
+              <p class="badge"><nut-badge :is-dot="item.isDot" :value="item.value" :max="99" top="0px" right="15px"></nut-badge></p>
+            </div>
+          </nut-cell>
         </div>
         <div slot="slipbtns" class="slipbtns"
-          ><a href="javascript:;" @click="delItem(index)">删除</a></div
-        >
+          ><a href="javascript:;" @click="delItem(index)">删除</a>
+        </div>
     </nut-leftslip>
 </div>
 ```
 
 ```javascript
+import Icon from '../icon/icon.vue';
+import Avatar from '../avatar/avatar.vue';
+import Badge from '../badge/badge.vue'
+
 export default {
     components: {},
     data() {
         return {
             list: [
-                {id: 'add1', addr: '北京市大兴区亦庄经济开发中心京东大厦B座1', tel: '159****8888'},
-                {id: 'add2', addr: '北京市大兴区亦庄经济开发中心京东大厦B座2', tel: '159****8888'},
-                {id: 'add3', addr: '北京市大兴区亦庄经济开发中心京东大厦B座3', tel: '159****8888'},
-                {id: 'add4', addr: '北京市大兴区亦庄经济开发中心京东大厦B座4', tel: '159****8888'},
-                {id: 'add5', addr: '北京市大兴区亦庄经济开发中心京东大厦B座5', tel: '159****8888'},
-                {id: 'add6', addr: '北京市大兴区亦庄经济开发中心京东大厦B座6', tel: '159****8888'},
-                {id: 'add7', addr: '北京市大兴区亦庄经济开发中心京东大厦B座7', tel: '159****8888'},
-                {id: 'add8', addr: '北京市大兴区亦庄经济开发中心京东大厦B座8', tel: '159****8888'}
-            ]
+                { id: 'add1', title: '噜啦噜1',subTitle:'我又来送福利啦!关注之后你就会',time:'10:13',isDot:false,value:9},
+                { id: 'add2', title: '噜啦噜2',subTitle:'我又来送福利啦!关注之后你就会',time:'10:12',isDot:true,value:1},
+                { id: 'add5', title: '噜啦噜5',subTitle:'我又来送福利啦!关注之后你就会',time:'1小时前',isDot:false,value:99},
+                { id: 'add8', title: '噜啦噜8',subTitle:'我又来送福利啦!关注之后你就会',time:'星期五' ,isDot:false,value:100}
+            ],
         };
     },
     methods: {
@@ -102,6 +104,25 @@ export default {
 };
 ```
 
+###  禁止滑动
+```html
+<div>
+    <button class="btn" @click="disabledHandle">{{isDisable ? '开启滑动' : '禁止滑动'}}</button>
+    <nut-leftslip :disabled="isDisable">
+        <div slot="slip-main" class="slip-main">左滑触发删除</div>
+        <div slot="slipbtns" class="slipbtns"><a href="javascript:;">删除</a></div>
+    </nut-leftslip>
+</div>
+```
+
+```javascript
+    disabledHandle(){
+        this.isDisable = !this.isDisable 
+    }
+
+```
+
+
 ## slot
 
 | 字段           | 说明                 | 类型    | 默认值 |
@@ -114,5 +135,6 @@ export default {
 | 字段 | 说明 | 类型 | 默认值
 |----- | ----- | ----- | ----- 
 | rightWidth | 右侧按钮区域超出一行时的默认宽度,默认占整个宽度的80% | Number | 0.8
+|  disabled  | 禁止滑动操作 | Boolean | false
 
 

+ 7 - 0
src/packages/leftslip/leftslip.vue

@@ -24,6 +24,10 @@ export default {
     rightWidth: {
       type: [Number, String],
       default: '0.8'
+    },
+    disabled:{
+      type: Boolean,
+      default: false
     }
   },
   data() {
@@ -75,6 +79,7 @@ export default {
     //   });
     // },
     touchStart(e) {
+      if(this.disabled) return false
       let parentElement = e.currentTarget.parentElement;
       let slip = [];
       slip = document.getElementsByClassName('leftslip-open');
@@ -92,6 +97,7 @@ export default {
     },
 
     touchMove(e) {
+      if(this.disabled) return false
       let parentElement = e.currentTarget.parentElement;
 
       let disX = e.touches[0].pageX - this.startX; // >0 右滑,<0 左滑
@@ -109,6 +115,7 @@ export default {
       }
     },
     touchEnd(e) {
+      if(this.disabled) return false
       let parentElement = e.currentTarget.parentElement;
       const disX = e.changedTouches[0].pageX - this.startX; // >0 右滑,<0 左滑
       let distance;

+ 31 - 0
src/packages/radio/demo.vue

@@ -130,6 +130,35 @@
         </span>
       </nut-cell>
     </div>    
+    <h4>标签样式</h4>
+    <nut-cell>
+        <span slot="title">
+          <nut-radio 
+          :type="'list'"           
+          :name="demo6name" 
+          :value="1"
+          :checked="false"
+          >
+          备选项1
+          </nut-radio>
+          <nut-radio 
+          :type="'list'"           
+          :name="demo6name" 
+          :value="2"
+          :checked="false"
+          >
+          备选项2
+          </nut-radio>
+          <nut-radio 
+          :type="'list'"           
+          :name="demo6name" 
+          :value="3"
+          :checked="false"
+          >
+          备选项3
+          </nut-radio>
+        </span>
+      </nut-cell>
   </div>
 </template>
 
@@ -143,6 +172,8 @@ export default {
       radioVal3: 'b',
       radioVal4: 'b',
       radioVal5: 'a',
+      demo6value:1,
+      demo6name:'test',
       radioGroupVal1: 'b',
       radioGroupVal2: '2',
       radioGroupVal3: '2',

+ 53 - 1
src/packages/radio/radio.scss

@@ -1,5 +1,7 @@
 @import '../../styles/animation/pulse';
-
+.warper{
+	display: inline-block;
+}
 .nut-radio {
 	margin-right: 10px;
 
@@ -92,3 +94,53 @@
 		}
 	}
 }
+.nut-radio-list{
+	display: inline-block;
+	text-align: center;
+	line-height: 28px;
+	height: 28px;	
+	position: relative;
+	font-size: 14px;
+	label{
+		display: inline-block;		
+		padding:0 15px;
+	}
+	input{
+		position: absolute;
+		opacity: 0;
+		z-index: 3;
+		top: 0;
+		left: 0;
+		width: 100%;
+		height: 100%;
+		display: block;
+		margin: 0;
+		padding:0;
+	}
+	.text-box{
+		position: relative;
+		z-index: 2;
+		color:#969696;
+	}
+	.box-border{
+		top:0;
+		left: 0;
+		position: absolute;
+		width: 100%;
+		height: 100%;
+		z-index: 1;
+		border-radius: 14px;	
+		background: rgba(255,255,255,1);
+		border: 1px solid rgba(230,230,230,1);
+	}
+	input:checked + .text-box{
+		color: #E1251B;
+		position: relative;
+		z-index: 2;
+	}
+	input:checked +.text-box + .box-border{
+		background: rgba(255,239,235,1);
+		border: 1px solid rgba(225,37,27,1);
+	}
+	
+}

+ 23 - 3
src/packages/radio/radio.vue

@@ -5,7 +5,7 @@
       type="radio"
       :value="currentValue"
       :class="{ 'nut-radio-ani': isAnimated }"
-      :checked="currentValue === label"
+      :checked="checked"
       :disabled="isDisabled"
       :label="label"
     />
@@ -13,8 +13,21 @@
       <slot></slot>
     </span>
   </label>
-  <div v-if="type === 'list'" class="list-box">
-
+  <div v-if="type === 'list'" class="nut-radio-list">
+      <label for="">
+          
+          <input
+            type="radio"
+            :value="currentValue"
+            :class="{ 'nut-radio-ani': isAnimated }"
+            :checked="checked"
+            :disabled="isDisabled"
+            :label="label"
+            :name="name"
+          />
+          <div class="text-box"><slot></slot></div>
+          <div class="box-border"></div>
+      </label>
   </div>
 </div>
   
@@ -30,6 +43,10 @@ export default {
       type: [String, Number, Boolean],
       default: false
     },
+    checked:{
+      type:Boolean,
+      default:false
+    },
     label: [String, Number, Boolean],
     size: {
       type: String,
@@ -46,6 +63,9 @@ export default {
     type:{
       type: String,
       default:'radio'
+    },
+    name:{
+      type:String
     }
   },
   data() {

+ 67 - 105
src/packages/uploader/demo.vue

@@ -1,26 +1,38 @@
 <template>
   <div class="demo-list">
-    <h4>基本用法</h4>
+    <h4>通用方法</h4>
+    <P>自定义样式,和图片预览</P>
     <div>
-      <nut-cell>
-        <span slot="title">
-          <nut-uploader
-            :name="name"
-            :url="url"
-            :xhrState="stateNum"
-            :acceptType="['image/jpeg', 'image/png', 'image/gif', 'image/bmp']"
-            @success="demo1Success"
-            @failure="demo1Fail"
-            @start="demo1UploadStart"
-            @showMsg="showMsg"
-          >{{demo1Name}}</nut-uploader>
-        </span>
-        <div slot="desc"></div>
-      </nut-cell>
+      <div class="preview-img-box">
+        <transition name="fade">
+            <div class="img-list" v-if="previewImg">
+              <img-cell v-for="(item,index) in previewImg" 
+                        :key="index"   
+                        :src="item"
+                        :clear="()=>{clearImg(index)}"
+                         /> 
+            </div>
+        </transition>
+        <nut-uploader
+              class="demo-1"
+              :name="name"
+              :url="url"
+              :xhrState="stateNum"
+              :acceptType="['image/jpeg', 'image/png', 'image/gif', 'image/bmp']"
+              :isPreview="true"
+              @preview="preview"
+              @success="demo1Success"
+              @failure="demo1Fail"
+              @start="demo1UploadStart"
+              @showMsg="showMsg"
+              :multiple="true"
+        >+</nut-uploader> 
+      </div>
+       
     </div>
 
-    <h4>高级用法</h4>
-    <p>结合Button组件和Toast组件使用</p>
+    <h4>其它用法</h4>
+    <p>1. 结合 Button 组件和 Toast 组件使用</p>
     <div>
       <nut-cell>
         <span slot="title">
@@ -39,40 +51,7 @@
         <div slot="desc"></div>
       </nut-cell>
     </div>
-
-    <p>结合进度条Progress组件使用,展示上传进度</p>
-    <div>
-      <nut-cell>
-        <span slot="title">
-          <nut-uploader
-            :name="name"
-            :url="url"
-            :xhrState="stateNum"
-            :headers="headers"
-            @success="demoSuccess"
-            @fail="demoFail"
-            @progress="progress"
-            @showMsg="showMsg1"
-            :clearInput="true"
-          >
-            <nut-button size="small">上传</nut-button>
-          </nut-uploader>
-        </span>
-        <div slot="desc"></div>
-      </nut-cell>
-      <nut-cell>
-        <span slot="title">
-          <nut-progress
-            class="progress-style"
-            :percentage="progressNum"
-            :showText="true"
-            strokeWidth="12"
-          />
-        </span>
-        <div slot="desc"></div>
-      </nut-cell>
-    </div>
-
+    
     <p>自定义headers&formData</p>
     <div>
       <nut-cell>
@@ -94,13 +73,11 @@
       </nut-cell>
     </div>
 
-    <p>预览上传图片</p>
+    <!-- <p>预览上传图片</p>
     <transition name="fade">
-      <div v-if="previewImg">
-        <div class="img-outbox" v-for="(item,index) in previewImg" :key="index">
-          <img class="img-box" v-if="item" :src="item" alt />
+        <div class="img-list" v-if="previewImg">
+          <img-cell v-for="(item,index) in previewImg" :key="index"   :src="item" /> 
         </div>
-      </div>
     </transition>
     <div>
       <nut-cell>
@@ -121,7 +98,7 @@
         </span>
         <div slot="desc"></div>
       </nut-cell>
-    </div>
+    </div> -->
     <p>上传图片前处理图片内容</p>
     <nut-cell>
       <span slot="title">
@@ -164,8 +141,11 @@
 </template>
 
 <script>
+import imgCell from "./img-cell";
 export default {
-  components: {},
+  components: {
+    imgCell
+  },
   data() {
     return {
       selfData: {
@@ -185,10 +165,16 @@ export default {
         f2: 'test1'
       },
       progressNum: 0,
-      previewImg: null
+      previewImg: []
     };
   },
   methods: {
+    clearImg(index){
+      // console.log(index)
+      // let ary =  JSON.parse(JSON.stringify(this.previewImg));
+      this.previewImg.splice(index,1)
+      // console.log(ary)
+    },
     test(event) {
       console.log(event, '可以处理input选择的内容');
       return {
@@ -226,8 +212,11 @@ export default {
     progress(file, loaded, total) {
       this.progressNum = parseInt((100 * loaded) / total);
     },
-    preview(file) {
-      this.previewImg = file;
+    preview(file) {      
+      
+      let previewImg = this.previewImg
+      this.previewImg = [...previewImg,...file]
+      
     },
     showMsg1(msg) {
       this.$toast.text(msg);
@@ -240,51 +229,24 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-.img-outbox {
-  margin-top: 20px;
-  margin-left: 20px;
-  width: 100px;
-  height: 100px;
-  border-radius: 6px;
-  position: relative;
-  border: 1px solid #f2f2f2;
-  line-height: 100px;
-  display: flex;
-  justify-content: center;
+.img-list{
+  display: flex;  
   align-items: center;
-
-  .img-box {
-    margin-top: 0;
-  }
-
-  .icon {
-    width: 20px;
-    height: 20px;
-    position: absolute;
-    z-index: 2;
-    top: 0;
-    right: 0;
-  }
-
-  .pr {
-    position: absolute;
-    z-index: 2;
-    top: 0;
-    left: 0;
-    width: 100%;
-    height: 100%;
-    color: #fff;
-    font-size: 16px;
-    text-align: center;
-    line-height: 100px;
-    background: rgba(0, 0, 0, 0.2);
-  }
+  flex-wrap: wrap;
 }
 
-.img-box {
-  margin-top: 20px;
-  max-width: 100%;
-  max-height: 100%;
-  border-radius: 6px;
+.demo-1{
+  width: 75px;
+  height: 75px;
+  line-height: 75px;
+  text-align: center;
+  border: 1px solid rgba(230,230,230,1);
+  border-radius: 3px;
+  background: #fff;
+}
+.preview-img-box{
+  display: flex;  
+  padding: 10px ;
+  flex-wrap: wrap;
 }
 </style>

+ 84 - 23
src/packages/uploader/doc.md

@@ -2,27 +2,41 @@
 
 文件上传组件
 
-## 基本用法
+## 通用方法
+
+模版部分如下:要说的一点就是 `img-cell` 是为了 `demo` 展示而临时写的一个模块,所以不能直接使用,需要使用
+下面的模版。
 
 ```html
-<nut-uploader
-    name="uploader-demo"
-    :url="url"
-    :isPreview="true"
-    :acceptType = "['image/jpeg', 'image/png', 'image/gif', 'image/bmp']"
-    @start="onStart"
-    @success="onSuccess"
-    @fail="onFail"
-    @progress="onProgress"
-    @preview="onPreview"
-    @showMsg="showMsgFn"
-    typeError="对不起,不支持上传该类型文件!"
-    limitError="对不起,文件大小超过限制!"
->
-上传
-</nut-uploader>   
+<div class="preview-img-box">
+  <transition name="fade">
+      <div class="img-list" v-if="previewImg">
+        <img-cell v-for="(item,index) in previewImg" 
+                  :key="index"   
+                  :src="item"
+                  :clear="()=>{clearImg(index)}"
+                    /> 
+      </div>
+  </transition>
+  <nut-uploader
+        class="demo-1"
+        :name="name"
+        :url="url"
+        :xhrState="stateNum"
+        :acceptType="['image/jpeg', 'image/png', 'image/gif', 'image/bmp']"
+        :isPreview="true"
+        @preview="preview"
+        @success="onSuccess"
+        @failure="onFail"
+        @start="onStart"
+        @showMsg="showMsgFn"
+        :multiple="true"
+  >+</nut-uploader> 
+</div>
 ```
 
+主要使用了 `@preview` 、 `@success` 、`@failure`、 ` @start`、 `@showMsg` 5个 事件监听上传的整个过程,代码部分如下:
+
 ```javascript
 export default { 
   data() {
@@ -39,11 +53,8 @@ export default {
       },
       onFail(file,res){
         alert('上传失败!');
-      },
-      onProgress(file, loaded, total) {
-        console.log('上传进度:'+parseInt((100 * loaded) / total)+'%');
-      },
-      onPreview(file) {
+      },     
+      preview(file) {
         this.previewImg = file;
       },
       showMsgFn(msg){
@@ -52,7 +63,57 @@ export default {
   }
 ```
 
-## 高级用法
+img-cell 模版代码如下:
+
+```html
+<template>
+    <div class="img-outbox">  
+        <i class="close" @click="close"></i>      
+        <img class="img-box" v-if="src" :src="src" alt />        
+    </div>
+</template>
+<script>
+export default {
+    name:"img-cell",
+    props:['src','clear'],
+    methods:{
+        close(){
+            if(Object.prototype.toString.apply(this.clear) === '[object Function]'){
+                this.clear()
+            }            
+        }
+    }
+}
+</script>
+<style lang="scss" scoped>
+    .img-outbox{
+        width: 76px;
+        height: 76px;
+        border-radius: 3px;
+        position: relative;
+        display: inline-flex;
+        align-items: center;
+        margin-right: 14px;
+        .close{
+            position: absolute;
+            display: block;
+            background: url(./../../assets/img/img-clear.png) no-repeat;
+            background-size: cover;;
+            width: 18px;
+            height: 18px;       
+            top:-9px;
+            right:-9px;    
+            cursor: pointer;
+        }
+        .img-box{
+            width: 100%;
+        }
+    }
+</style>
+```
+
+
+## 其它用法
 
 与吐司 **Toast** 组件结合使用
 

+ 44 - 0
src/packages/uploader/img-cell.vue

@@ -0,0 +1,44 @@
+<template>
+    <div class="img-outbox">  
+        <i class="close" @click="close"></i>      
+        <img class="img-box" v-if="src" :src="src" alt />        
+    </div>
+</template>
+<script>
+export default {
+    name:"img-cell",
+    props:['src','clear'],
+    methods:{
+        close(){
+            if(Object.prototype.toString.apply(this.clear) === '[object Function]'){
+                this.clear()
+            }            
+        }
+    }
+}
+</script>
+<style lang="scss" scoped>
+    .img-outbox{
+        width: 76px;
+        height: 76px;
+        border-radius: 3px;
+        position: relative;
+        display: inline-flex;
+        align-items: center;
+        margin-right: 12px;        
+        .close{
+            position: absolute;
+            display: block;
+            background: url(./../../assets/img/img-clear.png) no-repeat;
+            background-size: cover;;
+            width: 18px;
+            height: 18px;       
+            top:-9px;
+            right:-9px;    
+            cursor: pointer;
+        }
+        .img-box{
+            width: 100%;
+        }
+    }
+</style>

+ 3 - 5
src/packages/uploader/uploader.vue

@@ -76,7 +76,7 @@ export default {
         },
         clearInput: {
             type: Boolean,
-            default: false
+            default: true
         },
         xmlError: {
             type: String,
@@ -128,8 +128,7 @@ export default {
                 onProgress(file, loaded, total) {
                     _this.$emit("progress", file, loaded, total);
                 },
-                onPreview(previewFile) {
-					debugger
+                onPreview(previewFile) {				
                     _this.$emit("preview", previewFile);
                 },
                 onSuccess(file, responseTxt) {
@@ -150,8 +149,7 @@ export default {
             const formData = new FormData();
             const opt = this.createUploaderOpts();
             opt.$el = tar;
-            if (this.isPreview) {
-				debugger
+            if (this.isPreview) {				
                 opt.previewData = tar.files;
 			}
 			let len = this.multiple ? tar.files.length : 1;