gpt4 book ai didi

javascript - 如何对 Playground 中闪电网络组件 "datatable"的 tds 应用一些简单的样式?

转载 作者:行者123 更新时间:2023-12-04 21:28:48 26 4
gpt4 key购买 nike

playground of lightning web components 工作.我有以下文件和代码:

基本.html

<template>
<div style="height: 300px;">
<lightning-datatable
key-field="id"
data={data}
columns={columns}>
</lightning-datatable>
</div>
</template>

基本的.css
 td{
background: red;
}
:host td{
background: red;
}

基本.js
import { LightningElement, track } from 'lwc';
import fetchDataHelper from './fetchDataHelper';

const columns = [
{ label: 'Label', fieldName: 'name' },
{ label: 'Website', fieldName: 'website', type: 'url' },
{ label: 'Phone', fieldName: 'phone', type: 'phone' },
{ label: 'Balance', fieldName: 'amount', type: 'currency' },
{ label: 'CloseAt', fieldName: 'closeAt', type: 'date' },
];

export default class BasicDatatable extends LightningElement {
@track data = [];
@track columns = columns;

async connectedCallback() {
const data = await fetchDataHelper({ amountOfRecords: 100 });
this.data = data;
}
}

当我查看开发人员工具>检查时,它会在样式标签中呈现样式并且不适用于元素:
<style type="text/css">
td[c-basic_basic]{background: red;}
[c-basic_basic-host] td[c-basic_basic]{background: red;}
</style>

Link to the play ground I am working on

最佳答案

关于javascript - 如何对 Playground 中闪电网络组件 "datatable"的 tds 应用一些简单的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58839197/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com