javascript - 如何将 lit-html 添加到现有项目中?
问题描述
我知道我可以lit-html
使用<script type="module">
say 中的标签导入index.html
,但我无法访问html
或render
从单独的 JS 脚本(例如index.js
)。这目前可能吗?
解决方案
很抱歉回答了一个老问题,但文档可能自 2018 年以来已更新。现在他们提供了有关如何执行此操作的说明。
npm install lit-html
然后像这样导入到你的 JS 文件中:
import {html, render} from './node_modules/lit-html/lit-html.js';
html
然后在需要的地方打电话render()
(https://lit-html.polymer-project.org/guide/getting-started#rendering-a-template)。
推荐阅读
- numpy - 如何沿单个 pytorch 张量的维度连接?
- android - 是否可以在 Uiautomator 中不用手指向上滑动左右滑动?
- jquery-select2 - 将普通 select 转换为 select2 但保留宽度和类
- r - ggplot2:重新排序图例中的项目
- excel - 使用 VBA 从 Sharepoint 中删除文件
- python - 关联表中有目的的MYSQL重复条目
- pine-script - 如何更改会话休息时间
- c++ - make_reverse_iterator(make_reverse_iterator(it)) 导致不同类型是否有原因?
- docker - DotNet Docker 构建失败
- python - 整个字符串没有大写