https://marmelab.com/react-admin/Inputs.html#arrayinput 示例涵盖了您拥有对象数组的情况:
backlinks: [
{
date: '2012-08-10T00:00:00.000Z',
url: 'http://example.com/foo/bar.html',
},
{
date: '2012-08-14T00:00:00.000Z',
url: 'https://blog.johndoe.com/2012/08/12/foobar.html',
}
]
Run Code Online (Sandbox Code Playgroud)
是否可以让它只使用一个字符串数组?
backlinks: ['a', 'b', 'c']
Run Code Online (Sandbox Code Playgroud) 我试图按顺序执行一系列的承诺,只有在前一个解决之后才进入下一个承诺.来自Bluebird文档:
直到前一个项目才会调用迭代器,并且迭代器为该项目返回的promise将被满足. http://bluebirdjs.com/docs/api/promise.mapseries.html
var Promise = require('bluebird');
function test(time) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
console.log(time);
resolve(time);
}, time);
});
}
Promise.mapSeries([test(2000), test(1000), test(500), test(3000)], function(a) {
return a;
}).then(function(results) {
console.log(results);
});
Run Code Online (Sandbox Code Playgroud)
我期望的是测试函数里面的console.log按顺序显示:2000,1000,500,3000.我希望这是因为正如文档所述,每个项目仅在前一个项目解决之后才会发生.相反,我得到500,1000,2000,3000,这反映了所有功能都是实时调用的.此外,结果确实以他们被调用的顺序显示结果,尽管这在此时是无关紧要的.
我在这里误解了什么吗?
我有一个引导下拉列表.它工作正常,但当我在通过菜单访问的页面内,然后它变得奇怪:
http://2.bp.blogspot.com/-vw49cpP7weo/UZw0Jh_zmhI/AAAAAAAACJc/oadR5CTIus0/s640/dropdown.png
您可以在图片中看到,菜单向右移动.
我粘贴代码:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html"><i class="icon-chevron-right"></i> Zimil Ltda</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<li><a href="index.html">Inicio</a></li>
<li><a href="acerca.html">Quienes somos</a></li>
<li class="active" class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="jubilados.html">
Productos <i class="icon-caret-down"></i></a>
<ul class="dropdown-menu">
<li><a href="jubilados.html">Préstamos a jubilados</a></li>
<li><a href="cbu.html">Préstamos CBU</a></li>
<li><a href="otros.html">Otros créditos</a></li>
</ul>
</li>
<li><a href="trabajar.php">Trabajá con nosotros</a></li>
</ul>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我有一个beforeSave
-callback,每当我创建一个新实体时都会被调用.但是当我编辑时,它根本就没有被调用.在文档中找不到任何可能有用的内容.
这是我的编辑功能:
public function edit($id = null) {
if (!$id) {
throw new NotFoundException(__('Invalid article'));
}
$article = $this->Articles->get($id);
if ($this->request->is(['post', 'put'])) {
$this->Articles->patchEntity($article, $this->request->data);
if ($this->Articles->save($article)) {
$this->Flash->success(__('Your article has been updated.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('Unable to update your article.'));
}
$this->set('article', $article);
}
Run Code Online (Sandbox Code Playgroud) 我在 SailsJs 中有一个项目,使用带有 mongodb 数据库的水线。我定义了一些字段,这些字段不是必填字段。我需要搜索未定义该字段的记录。例如:
{id: 10, name: "jj"}
{id: 11, name: "kk", surname: "sr"}
Run Code Online (Sandbox Code Playgroud)
我想搜索未定义姓氏的地方。任何人都知道如何做到这一点?
我试过了
{surname: null}
{surname: ''}
Run Code Online (Sandbox Code Playgroud)
没有什么会产生想要的结果。