我想知道如何在 lit-element 组件中显示两个不同的对象值
render() {
${this.providerList.map(function (provider) {
${this.query.map(function (query) {
return html`
<div class="card mb-4" style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.28);border: none">
<div class="card-body p-0">
<div class="row m-2">
<div class="col-sm-4">
<p>${provider.name} ${query.value}</p>
</div>
</div>
</div>
</div>
})}
`;})}
}
import { LitElement, html, css } from 'https://unpkg.com/@polymer/lit-element/lit-element.js?module';
export class Provider extends LitElement {
constructor(){
super();
this.providerList=[
{
id="1", name="fund" ,description: "Raising Funds"
},
{
id="2", name="transfer" ,description: "transfering money"
}
];
this.query=
{
value: "200", country:"SG"
}
}
render() {
${this.providerList.map(function (provider) {
${this.query.map(function (query) {
return html`
<div class="card mb-4" style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.28);border: none">
<div class="card-body p-0">
<div class="row m-2">
<div class="col-sm-4">
<p>${provider.name} ${query.value}</p>
</div>
</div>
</div>
</div>
})}
`;})}
}
}
预期输出
在渲染 html 中显示两个不同的对象值。