这令我困惑.我不知道怎么解释这个,但这是我的调试代码的样子.在它下面,您可以看到这两个日志的输出.第一个清楚地显示了我正在尝试访问的属性的完整JavaScript对象,但下一行代码我无法使用config.col_id_3访问它(请参阅屏幕截图中的"undefined"?).有谁能解释一下?我也可以访问除field_id_4之外的所有其他属性.
console.log(config);
console.log(config.col_id_3);
Run Code Online (Sandbox Code Playgroud)
这就是这些console.log()在Console中打印的内容

我刚刚开始使用ReactJS,而且我对我遇到的问题有点困惑.
我的应用程序本质上是一个带有过滤器的列表和一个更改布局的按钮.目前我使用的三个组成部分:<list />,< Filters />和<TopBar />,现在很明显,当我更改设置的< Filters />我想在引发一些方法<list />来更新我的看法.
如何让这3个组件相互交互,或者我是否需要某种全局数据模型,我可以在其中进行更改?
有没有办法将一个组件传递到另一个反应组件?我想创建一个模型反应组件并传入另一个反应组件以转换该内容.
编辑:这是一个reactJS codepen,说明我正在尝试做什么.http://codepen.io/aallbrig/pen/bEhjo
HTML
<div id="my-component">
<p>Hi!</p>
</div>
Run Code Online (Sandbox Code Playgroud)
ReactJS
/**@jsx React.DOM*/
var BasicTransclusion = React.createClass({
render: function() {
// Below 'Added title' should be the child content of <p>Hi!</p>
return (
<div>
<p> Added title </p>
{this.props.children}
</div>
)
}
});
React.renderComponent(BasicTransclusion(), document.getElementById('my-component'));
Run Code Online (Sandbox Code Playgroud) 我需要叠加显示在第一个模态上方,而不是在后面.
$('#openBtn').click(function(){
$('#myModal').modal({show:true})
});Run Code Online (Sandbox Code Playgroud)
<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div><div class="container"></div>
<div class="modal-body">
Content for the dialog / modal goes here.
<br>
<br>
<br>
<br>
<br>
<a data-toggle="modal" href="#myModal2" class="btn btn-primary">Launch modal</a>
</div>
<div class="modal-footer">
<a href="#" data-dismiss="modal" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
</div>
</div>
<div class="modal" id="myModal2" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" …Run Code Online (Sandbox Code Playgroud)javascript jquery modal-dialog twitter-bootstrap twitter-bootstrap-3
我想知道如何在Javascript中删除字符串的第一个和最后一个字符.
我的网址正在显示/installers/,我只想要installers.
有时会是/installers/services/,我只是需要installers/services.
所以我不能简单地删除斜线/.
我有2个分支,master和dev.
我在dev分公司,我想摘樱桃1从承诺master到dev.所以我做了
$ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad
Finished one cherry-pick.
Run Code Online (Sandbox Code Playgroud)
但是,当我做的git status和gitx,我没有看到我的承诺be530cec7748e037c665bd5a585e6d9ce11bc8ad在git的历史.
我怎样才能在dev分支中看到我的提交?
在Vue 2.0中,文档和其他人清楚地表明,从父母到孩子的沟通是通过道具进行的.
父母如何告诉孩子一个事件是通过道具发生的?
我应该只看一个名为事件的道具吗?这感觉不对,也没有替代方案($emit/ $on是孩子到父母,而中心模型是远程元素).
我有一个父容器,它需要告诉它的子容器,可以在API上使用某些操作.我需要能够触发功能.
我有一系列按钮,点击时会在按钮下方显示一个弹出菜单.我想将按钮的位置传递给视图.我怎样才能做到这一点?
ItemView = Backbone.View.extend({
tagName: 'li',
events: {
'click': 'showMenu'
},
initialize: function() {
_.bindAll(this, 'render');
},
render: function() {
return $(this.el).html(this.model.get('name'));
},
showMenu: function() {
var itemColl = new ItemColl();
new MenuView({collection: itemColl}); // how to pass the position of menu here?
}
});
Run Code Online (Sandbox Code Playgroud) 说,我有一个看起来像这样的数组:
var playlist = [
{artist:"Herbie Hancock", title:"Thrust"},
{artist:"Lalo Schifrin", title:"Shifting Gears"},
{artist:"Faze-O", title:"Riding High"}
];
Run Code Online (Sandbox Code Playgroud)
如何将元素移动到另一个位置?
我想举例,{artist:"Lalo Schifrin", title:"Shifting Gears"}到最后.
我尝试使用splice,如下所示:
var tmp = playlist.splice(2,1);
playlist.splice(2,0,tmp);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我正在学习和使用Backbone.js.
我有一个Item模型和一个相应的Item视图.每个模型实例都有item_class和item_id属性,我希望将它们反映为相应视图的"id"和"class"属性.实现这一目标的正确方法是什么?
例:
var ItemModel = Backbone.Model.extend({
});
var item1 = new ItemModel({item_class: "nice", item_id: "id1"});
var item2 = new ItemModel({item_class: "sad", item_id: "id2"});
var ItemView = Backbone.View.extend({
});
Run Code Online (Sandbox Code Playgroud)
我应该如何实现视图,以便视图的el将转换为:
<div id="id1" class="nice"></div>
<div id="id2" class="sad"> </div>
Run Code Online (Sandbox Code Playgroud)
在我看到的大多数示例中,视图的el用作无意义的包装元素,在其中必须手动编写"语义"代码.
var ItemView = Backbone.View.extend({
tagName: "div", // I know it's the default...
render: function() {
$(this.el).html("<div id="id1" class="nice"> Some stuff </div>");
}
});
Run Code Online (Sandbox Code Playgroud)
所以当渲染时,一个人得到
<div> <!-- el wrapper -->
<div id="id1" class="nice"> Some stuff </div>
</div>
Run Code Online (Sandbox Code Playgroud)
但这似乎是浪费 - 为什么有外部div?我想让el …
javascript ×9
backbone.js ×2
reactjs ×2
arrays ×1
cherry-pick ×1
console.log ×1
git ×1
jquery ×1
modal-dialog ×1
sorting ×1
string ×1
vue.js ×1
vuejs2 ×1