小编Ale*_*mbo的帖子

Vue.js - Typescript:对象文字中的预期方法速记

在我的输入组件中,我有这个代码是为了使输入上的 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)

你知道代码解决方案吗?

typescript vue.js

3
推荐指数
1
解决办法
5136
查看次数

标签 统计

typescript ×1

vue.js ×1