迷茫的小孟 2024-01-30 16:35 采纳率: 0%
浏览 6

layui step 的组件高度height 咋设置。

如果父div 没法设置height(因为是步骤表单,里面的内容高度是不确定的,有的比如500px,有点是动态的1000到1500px之间),然后里面的步骤表单又必须设置height 比如layui.step那个 如果组件设置height:100%的话又不显示(除非设置父类div高度),设置auto的话也是不显示
如解决问题,必有偿 。困扰了好多天了

img

 //  步骤条配置
    layui.config({
        base: './step-lay/'
    }).use(['form', 'step'], function ()
    {
        var $ = layui.$,
            form = layui.form,
            step = layui.step;
        // 获取 URL 参数中的当前步骤索引值
        var urlParams = new URLSearchParams(window.location.search);
        var currentStep = parseInt(urlParams.get('step')) || 0;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%',
            stepWidth: '92%',
            height: '100%',
            stepItems: [
                {title: '阅读须知'},
                {title: '填写信息'},
                {title: '上传材料'},
                {title: '结果领取'},
                {title: '申请成功'}
            ],

            // 设置当前步骤
            step: currentStep,
            // 监听步骤切换事件
            stepChange: function (currentStepIndex) {
                // 更新 URL 参数中的当前步骤索引值
                updateUrlParams(currentStepIndex);
            }
        });
        form.on('submit(formStep)', function (data) {
            step.next('#stepForm');
            return false;
        });

        form.on('submit(formStep2)', function (data) {
            step.next('#stepForm');
            return false;
        });
        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        $('.next').click(function () {
            step.next('#stepForm');
        });

        // 更新 URL 参数中的当前步骤索引值
        function updateUrlParams(currentStepIndex) {
            var url = new URL(window.location.href);
            url.searchParams.set('step', currentStepIndex.toString());
            var newUrl = url.toString();
            window.history.replaceState({path: newUrl}, '', newUrl);
        }
    });


  • 写回答

2条回答 默认 最新

  • 百锦再@新空间创想科技 优质创作者: 编程框架技术领域 2024-01-30 16:58
    关注

    自从贤心去了vue。我就抛弃了layui
    现在潜心vue呢。你也来呗。

    评论

报告相同问题?

问题事件

  • 修改了问题 1月30日
  • 创建了问题 1月30日