Skip to content

Instantly share code, notes, and snippets.

@czwen
Last active December 3, 2021 08:06
Show Gist options
  • Save czwen/960647ad26b625823b83c2b69c48b9f7 to your computer and use it in GitHub Desktop.
Save czwen/960647ad26b625823b83c2b69c48b9f7 to your computer and use it in GitHub Desktop.
el-input disable and clearable
<el-input
ref="carModelInput"
v-model="carModelSelected.label"
placeholder="请选择"
clearable
class="w300"
@clear="clearCarModel">
<el-button slot="append" icon="el-icon-search" @click="carTypeVisible = true" />
</el-input>
{
mounted () {
try {
const $carModelInput = this.$refs.carModelInput.$el
$carModelInput.className += ' is-disabled'
$carModelInput.firstElementChild.setAttribute('readonly', 'readonly')
} catch (e) {
console.log(e)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment