当我将项目添加到列表时
页面重新渲染
但是滚动条丢失(这意味着我看不到页面的其他部分)
在添加项目之前:
添加项目后:
添加项目(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/