el-form-item设置不可修改
时间: 2023-12-14 16:02:18 浏览: 234
要使el-form-item不可修改,可以使用readonly属性或disabled属性。添加readonly="true"或disabled="true"可以实现该功能。例如,在el-input或textarea元素上添加readonly="true"或disabled="true"属性即可。以下是示例代码:
```
<el-form-item label="用户:" :label-width="formLabelWidth">
<el-input type="textarea" readonly="true" v-model="formData.benchmarkDetail" clearable placeholder="请输入"></el-input>
</el-form-item>
<el-form-item label="昵称:" :label-width="formLabelWidth">
<el-input type="textarea" :disabled="true" v-model="formData.targetDetail" clearable placeholder="请输入"></el-input>
</el-form-item>
```
在上述代码中,readonly="true"将使第一个el-input元素只读,而:disabled="true"将使第二个el-input元素不可编辑。根据需求选择其中一种方法即可。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* *2* [web前端-vue中设置el-form-item是否可编辑](https://blog.csdn.net/MinggeQingchun/article/details/118737757)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文