用element-ui创建一个新增仓库的表单
时间: 2023-02-14 20:43:49 浏览: 59
首先,确保你已经安装了element-ui,并在项目中引入了它。
然后在需要使用的组件中,引入`el-form`和`el-form-item`组件。
示例代码如下:
```
<template>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="仓库名称" prop="name">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="仓库地址" prop="address">
<el-input v-model="form.address"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm">新增</el-button>
</el-form-item>
</el-form>
</template>
<script>
export default {
data() {
return {
form: {
name: '',
address: ''
}
}
},
methods: {
submitForm() {
this.$refs.form.validate((valid) => {
if (valid) {
// 提交表单
} else {
console.log('error submit!!');
return false;
}
});
}
}
}
</script>
```
上面示例中,使用了`el-form`和`el-form-item`组件创建了一个新增仓库的表单。使用了`el-input`组件创建输入框,使用了`el-button`组件创建提交按钮。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)