javascript - 为什么 Vue.js 使用单字标签 <component>,这违反了他们自己的风格指南?

标签 javascript html vue.js

因此,Vue.js 有自己的风格指南,其中明确指出(在“基本”部分)component names should be multi-word以防止“与现有和 future 的 HTML 元素发生冲突,因为所有 HTML 元素都是一个词”。

但他们使用 <component> dynamic components 的标签.我找不到 <component>在现有 HTML 标签列表中。 这是否意味着如果有一天 HTML 采用 <component>标签,Vue.js 将尝试解析它们并中断?

请澄清。

最佳答案

我相信 Vue.js 正在尽最大努力遵守 W3C 标准。

Relation to Custom Elements

You may have noticed that Vue components are very similar to Custom Elements, which are part of the Web Components Spec. That’s because Vue’s component syntax is loosely modeled after the spec. For example, Vue components implement the Slot API and the is special attribute. However, there are a few key differences:

The Web Components Spec has been finalized, but is not natively implemented in every browser. Safari 10.1+, Chrome 54+ and Firefox 63+ natively support web components. In comparison, Vue components don’t require any polyfills and work consistently in all supported browsers (IE9 and above). When needed, Vue components can also be wrapped inside a native custom element.

Vue components provide important features that are not available in plain custom elements, most notably cross-component data flow, custom event communication and build tool integrations.

其他阅读

HTML Components

The <COMPONENT> element serves as a container to identify an HTML Component. It is not required; however, in many instances it may be useful in order to help the consumer of the HTML Component determine that an event was in fact fired from this particular component . The <COMPONENT> element serves to bind together the properties, methods and events as well as to provide a location for the identifier of this HTC.

它还指定了