简体   繁体   English

返回箭头 function 在同一行,typescript

[英]return of arrow function on the same line, typescript

I have the following code:我有以下代码:

computed: {
  todos(): Todo[] {
    return this.$store.getters['todos/list']
  }
}

but I would like something like this::但我想要这样的东西::

computed: {
  todos: (): Todo[] => this.$store.getters['todos/list']
}

nas I get the following error nas我收到以下错误

在此处输入图像描述

on terminal在终端上在此处输入图像描述

how to make it work so that the computed property returns on the same line?如何使其工作以使计算属性在同一行返回?

thanks for everything感谢一切

Actually you shouldnt do it like that.其实你不应该那样做。 Its described in the docs它在文档中描述

在此处输入图像描述

https://v2.vuejs.org/v2/guide/instance.html#Lifecycle-Diagram https://v2.vuejs.org/v2/guide/instance.html#Lifecycle-Diagram

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM