template
<el-form-item label="上传图片" :rules="[{ required: true, message: '必须要上传图片', trigger: 'blur' }]"
prop="image">
<el-upload
:action=webSite
class="upload-demo"
drag
:limit="1"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-remove = "handleRemove"
:show-file-list="true" >
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过4M</div>
</el-upload>
</el-form-item>
属性绑定变量时前面加:
在data中直接进行定义即可
data() {
return {
dialogTableVisible: false,
dialogFormVisible: false,
formLabelWidth: '100px',
form: {
show: true,
},
webSite: this.$webSite + "/manage/image_upload/"
}
},