代码之家  ›  专栏  ›  技术社区  ›  howMuchCheeseIsTooMuchCheese

如何向现有项目中添加lit html?

  •  0
  • howMuchCheeseIsTooMuchCheese  · 技术社区  · 7 年前

    我知道我可以进口 lit-html 使用 <script type="module"> 插话 index.html ,但我无法访问 html 或 render 从一个单独的JS脚本(例如。 index.js ).目前可能吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   salsbury    5 年前

    很抱歉回答了一个老问题,但这些文档可能从2018年起就已经更新了。现在,他们提供了如何做到这一点的说明。

    Install lit-html with npm :

    npm install lit-html

    然后 import into your JS file 这样地:

    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 ).

        2
  •  0
  •   aditya agnihotri    7 年前

    在索引中使用此CDN。html

    <script>https://cdn.jsdelivr.net/npm/lit-html@0.13.0/lit-html.d.ts</script>
    <script>https://cdn.jsdelivr.net/npm/lit-html@0.13.0/lit-html.d.ts.map</script>
    <script>https://cdn.jsdelivr.net/npm/lit-html@0.13.0/lit-html.js.map</script>
    

    希望这能解决我们的问题