(评论)
(comments)
原始链接: https://news.ycombinator.com/item?id=38251330
根据所提供的文本材料回答您的问题,根据给定的上下文,Lit 允许 Web 组件在 JavaScript 之前渲染的说法是正确的。 然而,它指出它存在潜在的问题,例如需要数十个新的网络标准来解决自己造成的伤害,并且与传统的 React 组件功能相比工作方式有所不同。 尽管依赖程度比 Vue 少,Lit 仍然在 Angular 的轻量级版本中运行。 此外,本文讨论了 HTML 和 JavaScript Web 组件之间的差异,并指出“HTML Web 组件”并不真正存在,而仅仅是 HTML。 尽管如此,“Web 组件还是很有用的”,特别是在组件除了包含核心 HTML 内容之外还需要通过附加功能来增强的情况下。 文中承认 Web 组件带来了挑战,例如迫使设计人员采用面向对象的编程原则以及添加 TS 使问题进一步复杂化。 最后,文本建议向客户端发送预渲染的 HTML 片段可以提供服务器端渲染组件的外观,类似于 Web 组件。 然而,服务器渲染组件的能力目前并不完全可行。 根据有关声明性 Shadow dom 的参考文献,目前主流浏览器并未广泛支持它。
I also think having a `user-avatar` take a `src` prop makes way more sense than having to add an `img` tag inside it everywhere I use it. In that case what am I saving? What is reusable?
Vue/React/Angular don't seem like they are trying to "replace" HTML (re: "XHTML wanted to replace HTML4, but HTML5 wanted to augment it. HTML5 won.", in the "On The Web, Augmentation Wins in the Long Run" section), they are taking HTML/CSS/JS and building on top of them. If they all used canvas to render instead I might buy that argument but they don't. They absolutely push those technologies to their breaking point but it's nothing short of amazing in my book what you can accomplish with them compared to just HTML/CSS/JS and even "web components".
I was excited when Web Components were first announced but they are incredibly lackluster with no "Batteries included" and feel like they don't really help you build web _apps_ like the frameworks do. Every alternative to the big frameworks (looking at you htmlx) feel like minor syntaxic sugar for jQuery and friends which feels like a massive step backwards and completely the wrong choice for building a web app.
reply