当我将项目添加到列表
时页面重新呈现
但滚动条丢失(这意味着我无法看到页面的其他部分)
在我添加项目之前:
我添加项目后:
添加项目(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 { overflow: scroll; }
添加到css文件中
但我仍然不知道为什么会发生
答案 0 :(得分:2)
您没有提供任何HTML。在包含所有这些的div容器中,您可以使用类似:
overflow-y: scoll
强制滚动条。