如何将Web组件编码的打字稿和SCSS转换为材料中的JavaScript和CSS(材料设计3)

发布于 2025-02-11 09:47:29 字数 1309 浏览 1 评论 0 原文

带有材料设计的材料网络2 ,我可以使用<<,我可以使用<<代码> MWC-button ,通过将模块从NPM软件包将模块从UNPKG或转移(或捆绑)导入到JavaScript文件(例如MWC-Bundle-button.js)。

<script defer
        type="module"
        src='https://unpkg.com/@@material/mwc-button?module'>
</script>
or
<script defer
        type="module"
        src='../(path)/web-components/mwc-bundle-button.js'>
</script>

<mwc-button label="button label"></mwc-button>

我想尝试一些材料的Web组件,但我不知道如何将存储库到JavaScript文件。

我尝试过,

  1. git克隆 lit启动器套件
  2. 在[LIT启动器套件] 构建(也许 tsc )中,下载材料-WEB存储库,
  3. 以转移到JavaScript文件
  4. lollup -c 对于捆绑包至一个JavaScript文件

ts2307:找不到模块'./lib/icon-styles.css'或其相应的类型声明。发生。

这是正确的方向吗? (我可以通过解决一些错误来实现目标吗?)

或者,我有误会吗?

Material Web with Material Design 2, I could use web components like mwc-button, by importing module from unpkg or transpiling (or bundling) to a JavaScript file (ex. mwc-bundle-button.js) from the NPM package.

<script defer
        type="module"
        src='https://unpkg.com/@@material/mwc-button?module'>
</script>
or
<script defer
        type="module"
        src='../(path)/web-components/mwc-bundle-button.js'>
</script>

<mwc-button label="button label"></mwc-button>

Material Web with Material You (Material Design 3), there are still no NPM package (@material/web) at 2022/06/29.

I want to try some web components with Material You, but I do not know how to transpile the repository to JavaScript files.

I tried,

  1. git clone Lit starter kit (maybe use Lit in material-web)
  2. download the material-web repository in the [Lit starter kit]
  3. build (maybe tsc) about icon.ts for transpiling to JavaScript files
  4. rollup -c for bundle to one JavaScript file

Then, TS2307: Cannot find module './lib/icon-styles.css' or its corresponding type declarations. is occurred.

Is this the right direction? (Can I reach the goal by solving some errors?)

Or, Do I have a misunderstanding?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月夜 2025-02-18 09:47:30

在2022/8/31,
有npm软件包@材料/web/web

然后,我可以使用bundling之类的Web组件(用)到NPM软件包中的JavaScript文件(ex。Bundle-md-outlined button.js)。

in 2022/8/31,
there is the NPM package @material/web.

Then, I can use web components like <md-outlined-button>, by bundling (with rollup.js) to a JavaScript file (ex. bundle-md-outlined-button.js) from the NPM package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文