【发布时间】:2018-04-11 16:31:22
【问题描述】:
我正在使用webcomponents-lite (Polymer) 创建网络组件。
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="styles.css">
<script type="text/javascript" src="/static/js/util.js"></script>
</head>
<body class="dark">
<main>
<edsp-login-form></edsp-login-form>
</main>
</body>
</html>
<edsp-login-form> 在使用lit-html 的js 文件中定义。定义如下:
@Define('edsp-login-form', {
style: ``
})
export class Login extends LitComponent {
render() {
return html`
<link rel="import" type="css" href="styles.css">`
<div></div>
}
}
在这段代码中,如何将 styles.css 中的 css 类应用到组件 <edsp-login-form>?
【问题讨论】:
-
在 edsp-login.html 中导入 style.css ,它现在可以使用,但很快就会被弃用
-
@NagaSaiA 试过但没用
-
也许你会对这篇文章感兴趣:stackoverflow.com/a/42764465/4600982
标签: css polymer web-component