账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    element-ui的el-tabs如何实现头部固定,panel超出高度滚动?
    35
    0
    element-ui的el-tabs如何实现头部固定,panel超出高度滚动?
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 芋头焖排骨 普通会员 1楼

      在Element UI中,可以通过自定义El-Tab组件和自定义El-Panel组件来实现头部固定,以及当El-Panel超出高度时滚动的功能。

      以下是一个简单的示例:

      1. 定义自定义El-Tab组件:

      ```javascript import { Tab, Panel } from 'element-ui';

      export default { extends: Tab, props: { name: { type: String, required: true }, content: { type: Array, default: () => [] }, header: { type: String, default: () => '' }, footer: { type: String, default: () => '' }, }, render: (h) => { return h('div', { key: this.$index, style: { position: 'fixed', top: 0, left: 0, width: '100%', height: '100%', overflow: 'auto', background-color: '#fff', zIndex: 9999, }, children: this.content.map((item, index) => h('div', { key: index, style: { position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center', top: ${index * 100}%, left: ${index * 100}%, padding: '10px', border: '1px solid #ccc', borderRadius: 5px, width: ${100 - item.length * 100}%, height: ${item.length * 100}%, overflow: 'hidden', }), })), footer: h('div', { key: this.$index, style: { position: 'absolute', bottom: 0, left: 0, width: '100%', height: '100%', overflow: 'auto', background-color: '#fff', zIndex: 9999, }, }), }); }, }; ```

      1. 定义自定义El-Panel组件:

      ```javascript import { Panel } from 'element-ui';

      export default { extends: Panel, props: { name: { type: String, required: true }, content: { type: Array, default: () => [] }, header: { type: String, default: () => '' }, footer: { type: String, default: () => '' }, }, render: (h) => { return h('div', { key: this.$index, style: { position: 'fixed', top: 0, left: 0, width: '100%', height: '100%', overflow: 'auto', background-color: '#fff', zIndex: 9999, }, children: this.content.map((item, index) => h('div', { key: index, style: { position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center', top: ${index * 100}%, left: ${index * 100}%, padding: '10px', border: '1px solid #ccc', borderRadius: 5px, width: ${100 - item.length * 100}%, height: ${item.length * 100}%, overflow: 'hidden', }), })), footer: h('div', { key: this.$index, style: { position: 'absolute', bottom: 0, left: 0, width: '100%', height: '100%', overflow: 'auto', background-color: '#fff', zIndex: 9999, }, }), }); }, }; ```

      然后在你的代码中使用这些组件:

      ```javascript

      ```

      在这个例子中,当用户点击Tab 1或Tab 2时,content数组中的相应项会显示。如果用户点击Tab 1,内容数组中的Tab 1会显示,内容数组中的Tab 2会隐藏,反之亦然。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部