1.vue画面调用js方法
<div :style="{marginTop:'100px',left: 0,bottom: 0,width: '100%',borderTop: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',textAlign: 'right',}">
<a-button :style="{marginRight: '8px'}" @click="onClose" >取消</a-button>
<a-button type="primary" @click="handleSubmit" >提交</a-button>
</div>
2.js方法 handleSubmit()
handleSubmit (e) {
e.preventDefault()// 取消事件的默认动作。
const _this = this
this.form.validateFieldsAndScroll((err, values) => { // 校验
values.content = _this.formData.content
if (!err) {
values.video = _this.formData.video
values.cover = _this.formData.cover
values.fileList = JSON.stringify(_this.handleFileList())
_this.loading = true
if (_this.handleFileList().videoUrl.length < 1) { // 视频非空校验
_this.$message.error('请重新上传视频')
_this.loading = false
return false
}
if (_this.handleFileList().coverUrl.length < 1) { // 图片非空校验
_this.$message.error('请重新上传封面')
_this.loading = false