我最近从 Angular 版本 14 迁移到版本 15(然后迁移到 16),并且使用 Angular Universal 进行预渲染似乎发生了变化:它似乎仍然有效,但熟悉的东西<!-- this page was prerendered with angular universal -->已经消失了。
问题:我可以不再依赖添加的 html 注释来快速验证、预渲染和 ssr 是否正常工作吗?即它消失了吗?如果是的话,为什么以及为什么我在网上找不到任何东西?如果不是,我在迁移过程中可能破坏了什么导致它死亡?
我想在我用 JS 创建的 img 上设置一个 data-src 属性。
为什么这不起作用?
const image = document.createElement('img');
image.className = 'restaurant-img';
image.src = '/img/1.jpg';
image.data-src = DBHelper.imageUrlForRestaurant(restaurant);
li.append(image);
Run Code Online (Sandbox Code Playgroud)
IDE 说:必须是左值
所以我不能分配它。
我还能如何在 img 上设置 data-src 然后从纯 JavaScript(无 jQuery);