css - 材质图标未在 Hyperhtml 中加载
问题描述
我在 Hyperhtml 组件中使用材质图标。但是即使加载了css,图标也不会加载到浏览器中。显示的是“3d_rotation”而不是图标。
这是我的实现。
const appIframeRender = hyperHTML.bind(document.querySelector('#iframe_element').attachShadow({mode: 'open'}));
const main2 = hyperHTML.wire();
appIframeRender`${[
cbplugin.CharmListComponent.render(main2)
]}`;
cbplugin.WrapperComponent.render = function (render, data){
return render`
<style>
@import "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css";
@import "https://fonts.googleapis.com/icon?family=Material+Icons";
@import "https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700";
</style>
<div>
<a class='dropdown-trigger card-more-actions' href='#' data-target='dropdown2'>
<i class="material-icons">
3d_rotation
</i>
</a>
</div>
}
所以我怀疑Hyper Html中是否可能不支持材质图标。材料图标 css 显示在检查元素样式中。
谢谢
解决方案
无论何时使用 Shadow DOM,都必须在主文档中导入字体:
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700">
</head>
...
推荐阅读
- python - Python Plotly 极坐标图切片对齐
- php - 如何使用 php 根据用户对选择表单的响应执行 sqlite 语句?
- r - 将 sapply 与具有多个参数的函数一起使用
- laravel - 复选框和图标在搜索时消失
- ssms - 我的多维数据集的分区会发生什么?
- java - 探针被标记为非空但为空
- user-interface - 在树莓派 4 上运行 PySide6
- visual-studio-code - 为什么在 Visual Code 中编译 Solidity 的智能合约会产生此错误:“ParserError: Expected identifier, got 'LParen'”
- grouping - 如何添加我们选择的组列名称
- vuejs3 - ApexCharts 在调整窗口大小之前不正确