在我的输入组件中,我有这个代码是为了使输入上的 v-model 作为一个组件工作:
computed: {
inputListeners: function() {
const vm = this;
return Object.assign({},
this.$listeners,
{
input: (event: any) => {
vm.$emit('input', event.target.value);
},
},
);
},
Run Code Online (Sandbox Code Playgroud)
这是官方示例:https : //vuejs.org/v2/guide/components-custom-events.html#Binding-Native-Events-to-Components
现在打字稿给我这个警告:
WARNING in /Users/../components/InputText.vue
Expected method shorthand in object literal ('{inputListeners() {...}}').
> inputListeners: function() {
Run Code Online (Sandbox Code Playgroud)
你知道代码解决方案吗?