首页 > 解决方案 > 在 ASP Net CORE MVC 项目中使用 Google Material UI

问题描述

如何将 Google Material Icons 添加到 MVC Net Core 项目中?我通过添加所有 zip 文件在我的项目文件夹中按照这些说明进行操作。只是好奇下一步是什么?

https://google.github.io/material-design-icons/

npm install material-design-icons

下面的这个链接已经过时了。

如何在 asp.net mvc 项目中使用 Material-UI

当前使用 MVC Core Net Core 2.2。公司不想应用 CDN URL 路由。

标签: javascriptc#cssasp.net-corematerial-design

解决方案


如果你曾经npm安装过,它会创建一个名为node_modules(可能隐藏在解决方案资源管理器中,点击Show All Files按钮查看)的文件夹。

您必须编写一些脚本(gulp、grunt 等)来将文件从node_modules目录移动到wwwroot/lib文件:

如何在 ASP.NET Core 中使用 npm

如何使用 ASP.NET Core v2 在 Visual Studio 2017 中安装 font-awesome

如果使用 gulp ,您可以尝试:

gulp.task('copy', ["clean"], function () {
    return gulp.src(['./node_modules/material-design-icons/iconfont/*'], {
        base: 'node_modules'
    }).pipe(gulp.dest('./wwwroot/lib'));
});

并且可以引用 .css 中的 css 文件_Layout.cshtml

注意:目前使用库管理器(LibMan)恢复material-design-icons在我的测试中总是失败。


推荐阅读