我想在Bootstrap中使用Lit-Element。
目前,我已按照此处的建议简单地导入了外部依赖关系:https://lit-element.polymer-project.org/guide/styles#external-stylesheet
是否有更好的方法导入这些第三方依赖?
这是我的组成部分:
import { LitElement, html, css } from "../../../third-party-libs/lit-element.js"
class LoginError extends LitElement {
static get properties() {
return {
show: { type: Boolean, reflect: true }
}
}
static get styles() {
return css`
div {
color: red;
}
.hide-me {
visibility: hidden
}
`;
}
constructor() {
super();
this.show = false
}
render(){
return html`
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<div class="invalid-credentials mb-3 animated ${ this.show ? "shake" : "hide-me"}">
Invalid credentials, please try again
</div>
`
}
}
customElements.define('login-error', LoginError)
我希望您能收到任何有关如何清理此问题以及如何与多个组件共享此代码的建议。
答案 0 :(得分:2)
您可以在获取样式中执行此操作,此代码提取全局样式并将其附加到shadowdom,因此组件会重新编辑引导程序,如果您想要其中的样式,您可以覆盖
# A tibble: 8 x 3
# N1 Outcome1 Outcome2
# <chr> <chr> <chr>
#1 "#7" #7 7
#2 "#7 #8" #7, #8 7, 8
#3 "#7,#8" #7, #8 7, 8
#4 "#07" #7 7
#5 "#/7" #7 7
#6 "#/\\7" #7 7
#7 "#7#8" #7, #8 7, 8
#8 "7 and 8" #7, #8 7, 8
答案 1 :(得分:0)
几件事:
祝你好运