【vue】form表单应用
【vue】form表单应用
·
一、参数解析:
- model:表单数据对象
- label-position:表单域标签的位置,若值为:left 或 right,需设置:label-width
- label-width:表单域标签的宽度,例如:50px,支持auto
- form表单,每个表单由一个form-item组件构成,可放置各种类型:input、select、checkbox、radio、switch、date-picker、time-picker、button。
二、前端页面
三、接口传参
四、源代码
<template>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="项目名称">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="私密项目">
<el-switch v-model="form.private"></el-switch>
</el-form-item>
<el-form-item label="业务线">
<el-select v-model="form.Line" placeholder="请选择业务线">
<el-option label="APP" value="app"></el-option>
<el-option label="WEB线" value="web"></el-option>
</el-select>
</el-form-item>
<el-form-item label="项目查看权限">
<el-radio-group v-model="form.power">
<el-radio label="所有人可见"></el-radio>
<el-radio label="仅创建者可见"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="项目标签">
<el-checkbox-group v-model="form.type">
<el-checkbox label="重点项目" name="type"></el-checkbox>
<el-checkbox label="敏捷开发" name="type"></el-checkbox>
<el-checkbox label="日常迭代" name="type"></el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="立项时间">
<el-col :span="11">
<el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%"></el-date-picker>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
<el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%"></el-time-picker>
</el-col>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="Save_project">保存</el-button>
</el-form-item>
</el-form>
</template>
<script>
import axios from'axios'
export default {
name: "test",
data() {
return {
form: {
name: '',
private:'',
Line:'',
power:'',
type:[],
date1:'',
date2:'',
}
}
},
methods: {
onSubmit() {
console.log('submit!');
},
Save_project(){
axios.post('http://localhost:8000/save_project/',this.form).then(
this.$message({
message:"保存成功",
type:"success"
})
)
}
}
}
</script>
<style scoped>
</style>
更多推荐
已为社区贡献2条内容
所有评论(0)