1.引入
~~~
import uploads from "@/components/uploads/uploads";
~~~
~~~
components:{
uploads
},
~~~
![](https://img.kancloud.cn/e6/64/e664742f759b526b733ab69a89b3662e_792x453.png)
2.引用
视频
size:视频大小(M)
isMore:true 多传 false 单传
isTitle:true 添加标题 false 不添加标题
title:标题
~~~
<el-form-item label="视频:" prop="video" v-if="is_show">
<el-input v-model="editForm.video" placeholder="请输入视频" :clearable="false" type="hidden"/>
<uploads type="video" :fileList="editForm.video" size="100" width="300px" height="300px" @success="uploadSuccess" :isMore="false" :isTitle="false"></uploads>
</el-form-item>
~~~
![](https://img.kancloud.cn/fe/9d/fe9d7cf4bfb8582ed0d2569fc837457d_1025x225.png)
js
~~~
uploadSuccess(res) {
this.$set(this.editForm,'video',res)
},
~~~
音频
~~~
<el-form-item label="音频:" prop="audio" v-if="is_show">
<el-input v-model="editForm.audio" placeholder="请输入音频" :clearable="false" type="hidden"/>
<uploads type="audio" :fileList="editForm.audio" size="100" width="300px" height="50px" @success="uploadSuccess1" :isMore="false" :isTitle="false"></uploads>
</el-form-item>
~~~
js
~~~
uploadSuccess1(res) {
this.$set(this.editForm,'audio',res)
},
~~~
附件
~~~
<el-form-item label="附件:" prop="enclosure" v-if="is_show">
<el-input v-model="editForm.enclosure" placeholder="请输入附件" :clearable="false" type="hidden"/>
<uploads type="files" size="100" :fileList="editForm.enclosure" width="300px" height="50px" :isMore="true" @success="uploadSuccess2" :title="editForm.enclosure_title" :isTitle="true"></uploads>
</el-form-item>
~~~
js
~~~
uploadSuccess2(res,title) {
this.$set(this.editForm,'enclosure',res)
this.$set(this.editForm,'enclosure_title',title)
},
~~~
methods中添加
![](https://img.kancloud.cn/57/6e/576e3b680f444004da25b33c4e04d8d0_524x364.png)
data->return 中添加
~~~
is_show:false
~~~
添加修改时将is_show设置为true
![](https://img.kancloud.cn/da/36/da36ac196feccc6873b4dd6b2f297476_844x149.png)
![](https://img.kancloud.cn/ba/36/ba36e5b75c83ea3b2f0a3830b3dbdff2_885x464.png)
验证将trigger设置为change
![](https://img.kancloud.cn/50/80/508077e9483718558d3c3747446d9005_929x423.png)