我有以下布局(我正在使用Meteor):
<template name="headerFooter">
<div class="container-fluid fill-height">
{{> header}}
{{> UI.contentBlock}}
{{> footer}}
</div>
</template>
<template name="home">
{{#headerFooter}}
<div class="row body-film">
<div id="newsfeed" class="col-sm-offset-7 col-sm-5 block-film">
{{#each stories}}
<div class="story">...</div>
{{/each}}
</div>
</div>
{{/headerFooter}}
</template>
Run Code Online (Sandbox Code Playgroud)
这个(相关)css支持它:
html {
height: 100%;
}
body {
min-height: 100%
}
.fill-height {
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
在html和body元素如预期都表现.它们以任何缩放级别或大小填充其区域.
但是,添加container-fluid的fill-height课程并没有完成这项工作.它只是包装它的内容,而不是填充到底部.这是一个问题,因为它负责添加body-film和block-film页面,这只是半透明的背景,给整个事物一些颜色统一.
以下是一些屏幕截图,所有页面都缩小了,因此内容不会填充高度:

现在这里body选择了元素.正如你所看到的,它填补了父母的权利.

但container-fluid事实并非如此.

随着fill-height我都试过height和min-height,他们看起来完全一样. …
我试图在一个RelativeLayout内部嵌套LinearLayout,并给它RelativeLayout一个边缘,使它的边缘远离边缘LinearLayout.到目前为止我有这个:
LayoutInflater.from(context).inflate(R.layout.conversation_view_layout, this, true);
this.setLayoutParams(new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
int tbm = AllConversationsActivity.topAndBottomMargin;
int lrm = AllConversationsActivity.leftAndRightMargin;
((MarginLayoutParams) this.getLayoutParams()).setMargins(lrm, tbm, lrm, tbm);
this.requestLayout();
Run Code Online (Sandbox Code Playgroud)
其中,如果我正确读取API,应将RelativeLayout的边距设置为指定的数字.它根本不是这样做的,而是setMargins()完全忽略了它.
另外,这是我的xml
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/conversation_picture"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/conversation_person"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/conversation_picture"
android:singleLine="true"
android:ellipsize="marquee"/>
<TextView
android:id="@+id/conversation_length"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/conversation_first_line"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/conversation_picture"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:ellipsize="end"/>
<TextView
android:id="@+id/conversation_last_time"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/conversation_first_line"
android:layout_alignParentLeft="true"
android:singleLine="true"
android:ellipsize="marquee"/>
Run Code Online (Sandbox Code Playgroud)
我怀疑这些视图RelativeLayout在进行对齐调用时强制边缘到父边缘.有人知道要设置这些边距需要做些什么吗?或者也许有更好的方法完全做到这一点?赞赏.
我正在使用从服务器中提取的json文件来配置我的网站,并告诉每个页面它的标题是什么.json文件如下所示:
[{"route": "student", "title": "Student Info Page"}, {"route": "payments", "title": "Payments and Pricing"}, {"route": "policy", "title": "Mine"}, {"route": "biography", "title": "About Me"}]
Run Code Online (Sandbox Code Playgroud)
用于使用以下代码创建导航栏:
App.MenuController = Ember.ArrayController.create();
$.get('config.json', function(data) {
App.MenuController.set('content', data);
});
Run Code Online (Sandbox Code Playgroud)
然后在模板中使用:
{{#each App.MenuController}}
{{#varLink route this}}{{title}}{{/varLink}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
到目前为止,这一切都很有效.
所以这是我的问题:我希望完成的路由映射App.Router.map以编程方式完成,使用此json对象来确定应存在哪些路由.
我该怎么做呢?我在文档中搜索过,然后尝试了这个:
$.get('config.json', function(data) {
App.MenuController.set('content', data);
for (var i = 0; i < data.length; i++) {
App.Router.map(function(){
var r = data[i].route;
console.log(r);
this.route(r);
});
}
});
Run Code Online (Sandbox Code Playgroud)
这给出了以下控制台读数:
student app.js:9
payments app.js:9
policy app.js:9
biography app.js:9
Assertion failed: …Run Code Online (Sandbox Code Playgroud) 我最近将我的Meteor应用程序部署到运行Ubuntu 14.04 x32的Digital Ocean液滴中.我在这个文件中使用了Meteor Upmup.json:
{
// Server authentication info
"servers": [
{
"host": "mycorrecthostname",
"username": "root",
"password": "mycorrectpassword"
}
],
// Install MongoDB in the server, does not destroy local MongoDB on future setup
"setupMongo": true,
// WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
"setupNode": true,
// WARNING: If nodeVersion omitted will setup 0.10.25 by default. Do not use v, only version number.
"nodeVersion": "0.10.28",
// Install PhantomJS in …Run Code Online (Sandbox Code Playgroud) 我有以下Meteor方法设置:
// Defined in collections/collections.js
Meteor.methods({
email: function(options) {
this.unblock();
Email.send(options);
}
});
Run Code Online (Sandbox Code Playgroud)
我称之为:
// Defined in client/main.js
Meteor.call('email', {
to: 'yeahright@noneya.com', from: 'yeahright@noneya.com',
text: 'testing testing'
});
Run Code Online (Sandbox Code Playgroud)
我在浏览器控制台中收到两个错误:
Exception while simulating the effect of invoking 'email'
ReferenceError {stack: "ReferenceError: Email is not defined? at Meteor…js?acc2397bd1f7321a583a30e0d4628ec4f9fded4b:369:3", message: "Email is not defined"}
ReferenceError: Email is not defined
(etc....)
Run Code Online (Sandbox Code Playgroud)
另一个在我的服务器shell中运行meteor:
Exception while invoking method 'email' ReferenceError: Email is not defined
(etc....)
Run Code Online (Sandbox Code Playgroud)
我正在使用pymongo来自不同系统的旧信息来播种数据库,我有很多这样的查询:
studentId = studentsRemote.insert({'price': price})
Run Code Online (Sandbox Code Playgroud)
在实际的python脚本中,它studentId打印为一个字符串,但在javascript Meteor应用程序中,我正在使用这些数据,它在任何地方都显示为ObjectId(...).
我想配置pymongo生成_id一个字符串而不打扰ObjectId
我使用Meteor规范创建的任何对象都将使用字符串格式,而不是ObjectId格式.我不希望在我的应用程序中混合使用id类型,因为它导致了我的互操作性问题.
我知道我可以从Meteor创建ObjectId但坦率地说我更喜欢使用字符串格式.它是Meteor默认的,它更简单,我找不到任何有理由在我的特定应用程序中使用ObjectId.
该valueOf()蒙戈功能或类似的东西可以解析_id和使用,一旦它在数据库中更新文件,但它会是不错的东西更直接.
我有以下模板:
<template name="modalTest">
{{session "modalTestNumber"}} <button id="modalTestIncrement">Increment</button>
</template>
Run Code Online (Sandbox Code Playgroud)
那个session助手只是与Session对象的中间人.我把它modalTestNumber初始化为0.
我希望将这个模板以及所有它的反应性渲染到一个bootbox模式对话框中.我为此模板声明了以下事件处理程序:
Template.modalTest.events({
'click #modalTestIncrement': function(e, t) {
console.log('click');
Session.set('modalTestNumber', Session.get('modalTestNumber') + 1);
}
});
Run Code Online (Sandbox Code Playgroud)
以下是我尝试过的所有内容以及它们的结果:
bootbox.dialog({
message: Template.modalTest()
});
Run Code Online (Sandbox Code Playgroud)
这会呈现模板,它或多或少看起来像0 Increment (in a button).但是,当我Session从控制台更改变量时,它不会更改,并且在单击按钮时不会调用事件处理程序(console.log甚至不会发生).
message: Meteor.render(Template.modalTest())
message: Meteor.render(function() { return Template.modalTest(); })
Run Code Online (Sandbox Code Playgroud)
这些都与Template调用本身完全相同.
message: new Handlebars.SafeString(Template.modalTest())
Run Code Online (Sandbox Code Playgroud)
这只是将模态体渲染为空.模态仍然弹出.
message: Meteor.render(new Handlebars.SafeString(Template.modalTest()))
Run Code Online (Sandbox Code Playgroud)
Template与纯粹的Meteor.render电话完全相同; 模板在那里,但没有反应或事件响应.
可能是我使用这种较少的引导包装而不是标准包装?
如何以适当的反应流星风格渲染?
我只是试图入侵bootbox.js文件本身,看看我是否可以接管.我改变了一些东西,以便在bootbox.dialog({})图层中我只传递我想渲染的模板的名称: …
是否可以使用Route 53指向mydomain.com/app与其他s3存储桶不同的s3存储桶之类的路径网址mydomain.com?
因此,例如:
mydomain.com/* 会指向 normal-bucket
mydomain.com/app 会指向 app-bucket
有必要改为仅使用像这样的子域app.mydomain.com吗?
路由规则可以做到这一点吗?
我有以下python代码:
print {a:b for a in [1, 2] for b in [3, 4, 5]}
Run Code Online (Sandbox Code Playgroud)
我希望能给我这样的东西:
{1:3, 1:4, 1:5, 2:3, 2:4, 2:5}
Run Code Online (Sandbox Code Playgroud)
但它反过来给了我这个:
{1: 5, 2: 5}
Run Code Online (Sandbox Code Playgroud)
我也有逆转,如环试了一下这里建议:
print {a:b for b in [3, 4, 5] for a in [1, 2]}
Run Code Online (Sandbox Code Playgroud)
但它仍然给了我错误的答案.而且我也在列表中尝试了同样的理解:
print [(a, b) for a in [1, 2] for b in [3, 4, 5]]
Run Code Online (Sandbox Code Playgroud)
这与预期完全一致.
我对字典有什么看法?
仅供参考,python命令返回:
Python 2.7.4 (default, Apr 19 2013, 18:32:33)
[GCC 4.7.3] on linux2
Run Code Online (Sandbox Code Playgroud) meteor ×5
mongodb ×2
amazon-s3 ×1
android ×1
bootbox ×1
css ×1
dictionary ×1
ember.js ×1
html ×1
javascript ×1
less ×1
meteor-up ×1
modal-dialog ×1
nested-loops ×1
pymongo ×1
python ×1
python-2.7 ×1
routes ×1
ssh ×1