我似乎无法让主题与LitElement一起工作。我可以设置设置的其他道具没有问题,但主题没有被Twind识别。还值得一提的是,我在编译时没有出错。有人能快速解决吗?
import {LitElement, html} from 'lit';
import {setup, warn, create, cssomSheet} from 'twind';
setup({
mode: warn,
theme: {
colors: {
purple: '#2013',
},
},
});
const sheet = cssomSheet({target: new CSSStyleSheet()});
const {tw} = create({sheet});
export class MyApp extends LitElement {
static styles = [sheet.target];
static get properties() {
return {
name: {type: String},
};
}
constructor() {
super();
this.name = 'World';
}
render() {
return html` <h1 class="${tw`text(3xl purple)`}">${this.name}!</h1> `;
}
}
window.customElements.define('my-app', MyApp);发布于 2022-04-02 10:59:30
很可能,问题是影子王国。如果您可以使用Twind,您可以尝试渲染到光域,而不是影子域.
要在web组件类中添加光照,请使用以下方法:
createRenderRoot() {
return this;
}另一方面,如果没有灯光我不确定它是否有效..。
https://stackoverflow.com/questions/71392945
复制相似问题