[英]Is it a convention to start filename with 'use' when naming Vue 3 js modules?
I've started using the new Vue 3 for months, there seems to be no style guide for new Vue 3 since the official release in September.我已经开始使用新的 Vue 3 几个月了,自从 9 月份正式发布以来,似乎没有新的 Vue 3 风格指南。 So far I just see the most comprehensive documentation here:
到目前为止,我只在这里看到了最全面的文档:
Vue Composition api Vue 组合 API
I find that the example js module names usually have the prefix "use" in the documentation and in some online tutorials.我发现示例 js 模块名称在文档和一些在线教程中通常带有前缀“use”。 Foe example, useMousePosition.js .
例如, useMousePosition.js 。 I just wonder if it's a convention and is there any meaning behind the prefix "use"?
我只是想知道这是否是一种约定,前缀“使用”背后是否有任何含义?
And one more question, I keep most "non-UI" logics in the js files, and UI-related data and methods in vue files.还有一个问题,我在js文件中保留了大多数“非UI”逻辑,而在vue文件中保留了与UI相关的数据和方法。 This was also my approach when doing in the old Vue 2. Is this a proper way also when working in Vue3 ?
这也是我在旧的 Vue 2 中使用的方法。在 Vue3 中工作时这也是一种正确的方法吗?
Thank you!谢谢!
The Composition API RFC
covers this in this section . Composition API RFC
在本节中涵盖了这一点。
Excerpt摘抄
Notice how all the logic related to the create new folder feature is now collocated and encapsulated in a single function.
请注意与创建新文件夹功能相关的所有逻辑现在如何并置并封装在单个函数中。 The function is also somewhat self-documenting due to its descriptive name.
由于其描述性名称,该函数也具有某种程度的自我记录。 This is what we call a composition function.
这就是我们所说的组合函数。 It is a recommended convention to start the function's name with use to indicate that it is a composition function .
推荐的约定是函数名以 use 开头,以表明它是一个组合函数。 This pattern can be applied to all the other logical concerns in the component
这种模式可以应用于组件中的所有其他逻辑问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.