Passing arguments to getter could not be traceable in Webstorm (maybe other IDE too) #2547
Unanswered
stanleyxu2005
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Some help is needed.
The official example shows how to pass args into getter methods.
这是官方文档中关于带参数的getter的定义方法
I'm afraid it will lose tracking of usage when I track such a getter method.
我在实际使用中发现,一旦代码中使用这种getter,那么IDE自带的调用追溯功能将失效。
In the example, the method is used with argument but in the definition the argument is wrapped in the inner funciton.
原因是实际使用的参数,并没有在getter中定于,而是在函数体中新创建的函数里定义了。
Currently I have to define
getUserById
in actions.我目前暂时把所有带参数的getter,定义成了action。
However I dont think this is an action. Action normally triggers a state mutation, right?
但我感觉这并不是一个合理的用法,因为action是用来修改state状态的,而不是服务于查询。
我的理解有问题吗?
Beta Was this translation helpful? Give feedback.
All reactions