H5W3
当前位置:H5W3 > 问答 > 正文

初学element-ui,如何给el-input设置默认值

<el-form
:inline="true"
v-if="addReceivablesVisible"
:model="addReceivables"
ref="addReceivablesRef"
class="demo-form-inline my-el-form"
>
<div v-if="index == addReceivables.domains.length-1"
v-for="(receivablesItem,index) in addReceivables.domains"
:key="index"
>
<el-form-item label
style="width:130px;"
:prop="'domains.'+index+'.name'"
:rules="{ required: true, message: '请选择费用名称', trigger: 'change' }"
>
<el-select v-model="receivablesItem.name" size="small" placeholder="请选择">
<el-option v-for="item in priceTypeList"
:key="item.id"
:label="item.name"
:value="item.name"
/>
</el-select> </el-form-item> <el-form-item label
:prop="'domains.'+index+'.receipts'"
:rules="{ type: 'number', required: true, message: '金额必须为数字值'}"
>
<el-input-number v-model.number="receivablesItem.receipts"
style="width:125px;"
class="my-el-input-number"
:controls="false"
precision="2"
:min="1"
:max="100000"
size="small"
/>
</el-form-item> <!-- <el-form-item
label :prop="'domains.'+index+'.discounts'" :rules="{ type: 'number', required: true, message: '金额必须为数字值'}" > <el-input-number v-model.number="receivablesItem.discounts"         class="my-el-input-number"
:controls="false" precision="2" :min="0" :max="100000" size="small" /> </el-form-item> --> <el-form-item
label
style="width:120px;"
:prop="'domains.'+index+'.way'"
:rules="{ required: true, message: '请选择收费方式', trigger: 'change' }"
>
<el-select v-model="receivablesItem.way" size="small" placeholder="请选择">
<el-option v-for="item in wayList"
:key="item.id"
:label="item.name"
:value="item.code"
/>
</el-select> </el-form-item> <el-form-item label
style="width:120px;"
:prop="'domains.'+index+'.remarks'"
:rules="{ min: 0, max: 100, message: '备注为100字以内', trigger: 'blur' }"
>
<el-input v-model="receivablesItem.remarks" size="small" placeholder="请输入"/>
</el-form-item> <el-form-item label>
<el-button type="text"
style="color:#47b579;"
@click.prevent="submitAddReceivables('addReceivablesRef',receivablesItem)"
>确认
</el-button>
</el-form-item> </div></el-form>
<div v-if="index == addReceivables.domains.length-1"
v-for="(receivablesItem,index) in addReceivables.domains"
:key="index"
>
<el-input v-model="receivablesItem.remarks" size="small" placeholder="请输入"/>

根据缓存,如何给el-input设置一个默认的值
这个el-input是el-form里面的,外面还有个轮询

回答

v-model是双向绑定,直接给值即可:


data() {
    reutrn {
        receivablesItem: {
            remarks: 123
        }
    }
}


this.receivablesItem.remarks = 123

就是用v-model啊

v-model 可以给input赋值

未经允许不得转载:H5W3 » 初学element-ui,如何给el-input设置默认值

赞 (0)

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址