vue的el-ui组件input的clearable和readOnly并存
问题看代码
12345<el-input placeholder="点击选择..." clearable></el-input><el-input placeholder="点击选择..." readonly></el-input>
以上代码只能二选一,如何突破限制我都想要呢?
解决方案12<el-input @hook:mounted="updateClearable" ref="showClearable" placeholder="点击选择图标" clearable></el-input>
12345methods: { updateClearable(){ this.$refs.showClearable.$refs.input.readOnly = true; }}
原理具体可分析一下源码:
123456789computed: ...