Vue.js 具有VueJS自动完成功能的元素UI:避免使用道具(Vue警告)
我对VueJS和元素UI有一个大问题 我使用自动完成组件,我希望我点击输入(onFocus事件),我的建议会重新出现Vue.js 具有VueJS自动完成功能的元素UI:避免使用道具(Vue警告),vue.js,autocomplete,prop,element-ui,Vue.js,Autocomplete,Prop,Element Ui,我对VueJS和元素UI有一个大问题 我使用自动完成组件,我希望我点击输入(onFocus事件),我的建议会重新出现 <el-autocomplete id="inputID" name="inputName" class="inputClass" v-model="inputModel" :fetch-suggestions="querySearchInput"
<el-autocomplete
id="inputID"
name="inputName"
class="inputClass"
v-model="inputModel"
:fetch-suggestions="querySearchInput"
placeholder= "Select an Input"
ref="inputReference"
value-key="id"
v-loading="inputLoader"
:value="inputValue"
@select="onChangeInput"
@focus="onFocusInput"
@clear="onClearInput"
clearable
>
<!-- Slot : Override Component Suggestions -->
<template slot-scope="{item}" v-if="item.id">
{{ item.id }} - {{ item.name }}
</template>
</el-autocomplete>
但它不会重置我的建议..:/
我唯一的方法是使用:
this.$refs.inputReference.value = "";
但这不是最好的做法,我有一条消息:“vue.esm.js?efeb:591[vue warn]:避免直接修改道具,因为每当父组件重新渲染时,该值将被覆盖。相反,使用基于道具值的数据或计算属性。修改道具:“值”
我在我的组件上使用:值和v型,因为我有一个ID,但我显示一个带有i18n的标签,这并不重要
非常感谢
我认为这是因为AutoComplete组件包括一个InputComponent,而我不是VueJS上具有级联特性的专业人士
谢谢。照上面说的做就行了。不要改变道具。如果需要更改道具的某些日期,请将其保存到本地组件数据并进行修改
道具:{
傅:{
类型:数字,
要求:正确
}
},
...
数据(){
返回{
localFoo:this.foo
}
}
PS:组件链接:谢谢,但我不在个人组件上。我有一个组件El autocomplete,它在自己的代码中调用输入,我没有访问权限哦,我明白了。您使用了值
绑定和v-model
,这是不正确的v-model='foo'
基本上是指:value='foo',@change='updateFoo'
。因此,您可能需要删除:value
并只保留v-model
。这是给你的信息。
this.$refs.inputReference.value = "";