Git Product home page Git Product logo

Comments (4)

mortalYoung avatar mortalYoung commented on May 20, 2024

可以提供更多的信息么 目前的信息看不出问题在哪里

from molecule.

YuanWangZai avatar YuanWangZai commented on May 20, 2024

这是完整的代码:

const BusInfo = (props: any) => {
    const {
        bus
    } = props

    const ConsTabItems: ITabProps[] = [
        {
            id: 'businfo_info',
            name: localize('', '信息'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
        },
        {
            id: 'businfo_bind',
            name: localize('', '绑定'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
        }
    ]

    const [tabItems, setTabItems] = useState(ConsTabItems)
    const [activeTab, setActiveTab] = useState('businfo_info')

    useEffect(() => {
    }, [])

    const handleSelTab = (id: any) => {
        setActiveTab(id)

    }
    return (
        <div >
            <div className={'bus-header'}>
                <span>{bus?.name}</span>
            </div>
            <div style={{ height: 300 }}>
                <Tabs
                    activeTab={activeTab}
                    data={tabItems}
                    onSelectTab={handleSelTab}
                    type={'card'} />
            </div>
        </div>
    )
}

export default BusInfo

我希望点击对应的Tab的时候在下方渲染出renderPane的内容,但是并没有,请问应该如何修改代码。另外有没有什么方法可以修改每个Tab显示文字的宽度,谢谢。
image

from molecule.

mortalYoung avatar mortalYoung commented on May 20, 2024

Molecule 这边的 Tabs 组件只负责渲染 Tabs 的 Header 内容。内容需要自行调用 renderPane 去渲染。至于 Tabs 的类型上会有 renderPane 的原因是因为 Molecule 里面复用了这个类型,这是一件可以优化点。事实上 Tabs 组件并没有用 renderPane。

可以参考 Panel 组件的源码实现:

https://github.com/DTStack/molecule/blob/57804b644880336cdcb6587d4f7517503ded9f62/src/workbench/panel/panel.tsx

另外有没有什么方法可以修改每个Tab显示文字的宽度

可以直接修改文案的 padding 值,比如:

.mo-panel__header .mo-tab__item{
    padding: 0 20px;
}

from molecule.

YuanWangZai avatar YuanWangZai commented on May 20, 2024

明白了,谢谢

from molecule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.