添加项目时 meteor 丢失滚动条

标签 meteor

当我将项目添加到列表时

页面重新渲染

但是滚动条丢失(这意味着我看不到页面的其他部分)

在添加项目之前:

enter image description here

添加项目后:

enter image description here

添加项目(js):

function resetForm () {
    form.reset();
    $("#goodImgPreview").attr('src', "");
    $('#addGoodModal').modal('hide');
}
uploadFile.read(file, function(err, upf) {
    // 展示 上传进度条
    Session.set('createGoodModalContentOnUpload', true);
    Meteor.call("upload", upf, function(err, fileId) {
        if (!err) {
            good.fileId = fileId;
            goodsCollection.insert(good);
            resetForm();
            Session.set('createGoodModalContentOnUpload', false);
        } else {
            Session.set('createGoodModalContentOnUpload', false);
        } 
    });
});

显示列表(html):

<div class="row">
    {{#each goodList}}
        {{> goodEdit}}
    {{/each}}
</div>


<template name="goodEdit">
    <div class="col-sm-3">
        <img src="/uploadDir/{{owner}}/{{fileId}}" alt="" width="160" height="160">
        <label for="">{{name}}</label>
    </div>
</template>

显示列表(js):

Template.shopEditGoods.goodList = function() {
    return goodsCollection.find({shopId: Session.get('shopId')});
}

路由器:

Router.map(function() {
    this.route('shopCreate', {path: '/shopCreate/'});

    this.route('shopEditBasic', {
    path: '/shop/edit/:_id/basic/',
        layoutTemplate: 'shopEditLayout',
        waitOn: function() {
            Session.set('shopId', this.params._id);
            Session.set('shopEditSideNav', 'shopEditBasic')
            return Meteor.subscribe('shop', this.params._id);
        }
    });

    this.route('shopEditGoods', {
        path: '/shop/edit/:_id/goods/',
        layoutTemplate: 'shopEditLayout',
        waitOn: function() {
            Session.set('shopId', this.params._id);
            Session.set('shopEditSideNav', 'shopEditGoods')
            Meteor.subscribe('usergoods');
            return Meteor.subscribe('shop', this.params._id);
        }
    });

    this.route('shopEditPrices', {
        path: '/shop/edit/:_id/prices/',
        layoutTemplate: 'shopEditLayout',
        waitOn: function() {
            Session.set('shopId', this.params._id);
            Session.set('shopEditSideNav', 'shopEditPrices')
            Meteor.subscribe('usergoods');
            return Meteor.subscribe('shop', this.params._id);
        }
    });
});

======================================

我找到了解决方案:添加html {溢出:滚动; } 到 css 文件 但我还是不知道为什么会这样

最佳答案

您尚未提供任何 html。在包含所有这些的 div 容器中,您可以使用类似以下内容的内容:

溢出-y:scoll

在你的CSS中强制滚动条。

关于添加项目时 meteor 丢失滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179687/

相关文章:

meteor - 当路由更改但模板保持不变时,如何让 onRendered 再次运行?

javascript - 如何使用 Meteor 进行账户输入?

javascript - 我需要在 Meteor 中生成一个随机数

javascript - 登录后根据配置文件参数路由用户

linux - 让 meteor 0.9.2 构建工作 OSX -> Linux

javascript - 将空格键参数传递给另一个空格键参数

python - Pymongo 使用字符串 ID 而不是 ObjectID 插入文档

javascript - 模板的 HTML 没有值

node.js - Meteor.js - 需要文件

join - 用于连接的 Meteor 发布关系 VS 收集助手?