跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 小白学 Vue, 一些编写规范问题,想请教一下

发表于

环境

vue3 + vite + js + css3 ; (学 VUE 2 周)

疑问 1 ;

假如我自定义一个组件 名字叫 MenuItem.vue 我在一个 Vue 文件里引入,那我使用这个组件 应该是?

1 <MenuItem /> 2 <MenuItem> <MenuItem/> 3<menu-item /> 4 <menu-item> <menu-item/>

ps: 我在 vue3 官网看到这段话 每太理解;

在单文件组件中,推荐为子组件使用 PascalCase 的标签名,以此来和原生的 HTML 元素作区分。虽然原生 HTML 标签名是不区分大小写的,但 Vue 单文件组件是可以在编译中区分大小写的。我们也可以使用 />来关闭一个标签.
如果你是直接在 DOM 中书写模板 (例如原生 <template> 元素的内容),模板的编译需要遵从浏览器中 HTML 的解析行为。在这种情况下,你应该需要使用 kebab-case 形式并显式地关闭这些组件的标签.

疑问 2 ;

在写项目的时候,目录结构怎么算是标准的,如文件夹名称,文件名称,组件名称,样式名称,布局组件?

举例: 我的 vue3 项目,src 下有,api,assets,components,layout,style,router,views;

components 和 layout 下,新建组件,比如一个 MenuItem.vue ,是建一个 MenuItem 文件夹里创建 index.vue ,还是直接建文件? 文件夹名称 和 文件名称 是否需要是驼峰 + 首字母大写? components 和 layout 下 的组件命名有区别吗?

css 的布局的文件,是单独放到 style 里 还是放到 assets 下,怎么算是标准的,我看一些大佬的 vue3 项目,他们写有的 scss 是 _xxxx.scss 还有 xxxx_.scss 命名有什么标准吗?

ps: 就是想问问,vue3 有没有说像 Java 有阿里巴巴开发规范手册一样,来规范标准化这些东西? 我参考了很多开源 基本都是按照自己的风格写的;

Featured Replies

No posts to show

创建帐户或登录来提出意见

Account

导航

搜索

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.