el-input輸入框值輸入無顯示怎么解決?


有時候el-input由於嵌套的層級比較多,數據雙向綁定無效。有兩種解決方案,一是減少層級的嵌套,這對於必須嵌套多層的頁面來說,無法解決。

第二種方法:在嵌套的無法進行動態綁定的頁面的輸入框上添加一個input事件,在input執行的方法中強制刷新數據:

<template>
    <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="必填項" prop="name">
            <el-input v-model="ruleForm.name" @input="inputChange"></el-input>
        </el-form-item>
    </el-form>
</template>

<script>
    export default { name: '', data() { return { ruleForm: {}, } }, methods: { inputChange(e) { //強制刷新 this.$forceUpdate() } } } </script> <style> </style>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM