我目前正在学习本教程:jQuery入门
对于以下两个示例:
$("#orderedlist").find("li").each(function (i) {
$(this).append(" BAM! " + i);
});
$("#reset").click(function () {
$("form").each(function () {
this.reset();
});
});
Run Code Online (Sandbox Code Playgroud)
请注意,在第一个示例中,我们使用$(this)
在每个li
元素中附加一些文本.在第二个示例中,我们this
在重置表单时直接使用.
$(this)
似乎比使用频率更高this
.
我的猜测是在第一个例子中,$()
将每个li
元素转换为理解append()
函数的jQuery对象,而在第二个示例中reset()
可以直接在表单上调用.
基本上我们需要$()
特殊的jQuery功能.
它是否正确?
我的节点webpack项目使用三个babel库.它们之间有什么区别?它们是如何被使用的?
"dependencies": {
"babel-runtime": "^5.8.24"
}
"dev-dependencies": {
"babel": "^5.8.23",
"babel-core": "^5.8.23"
}
Run Code Online (Sandbox Code Playgroud) 我正在查看一些ES6代码,我不明白@符号放在变量前面时的作用.我能找到最接近的东西与私人田地有关?
代码我从redux库中查看:
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'redux/react';
import Counter from '../components/Counter';
import * as CounterActions from '../actions/CounterActions';
@connect(state => ({
counter: state.counter
}))
export default class CounterApp extends Component {
render() {
const { counter, dispatch } = this.props;
return (
<Counter counter={counter}
{...bindActionCreators(CounterActions, dispatch)} />
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我发现的关于这个主题的博客文章:https://github.com/zenparsing/es-private-fields
在这个博客文章中,所有示例都在一个类的上下文中 - 在模块中使用符号时它意味着什么?
我在没有UI的情况下使用android模拟器,而"Home"的键盘命令是Home键,但我的macbook没有主页键.有人知道命令是什么吗?
我正在使用实验室编写测试用例,我想测试是否从我的插件中抛出异常.问题是,hapi允许异常冒泡,同时还设置对内部服务器错误500的响应,这导致我的测试失败.
我们可以测试这个响应,expect(res.statusCode).to.equal(500)
但测试仍然会失败.
我不能使用try/catch,server.inject
因为异步是异步抛出的.
如何使用实验室测试异常?
我正在查看 Mongoose 中 Document#update 的示例:
http://mongoosejs.com/docs/api.html#document_Document-update
方法签名:
文档#更新(文档,选项,回调)
示例代码:
奇怪的汽车.更新({$inc: {wheels:1}}, { w: 1 }, 回调);
文档说第一个参数应该是“doc”,但究竟什么是 doc?我想 doc 应该只是一个将键映射到要更新的新值的对象(默认情况下使用 $set )。在代码示例中,他们试图将轮子增加 1。
然后在示例中,他们将 {w : 1} 作为选项传递,但根据 Model.Update,“w”不是有效选项。唯一有效的选项应该是:safe、upsert、multi、strict。
http://mongoosejs.com/docs/api.html#model_Model.update
有人可以解释一下 Mongoose 提供的示例代码吗?
我正在查看 hapi 路由的一些身份验证配置选项。我了解范围是如何工作的 - 您可以设置路由的范围,'admin'
这意味着用户的凭据必须具有匹配的范围......但是目的是entity
什么?
以下是文档:
当我'user'
在路线上设置实体时,我收到此错误:
"message": "Application credentials cannot be used on a user endpoint"
这让我相信我的身份验证插件正在将我的实体设置为'app'
?作为参考,我正在使用hapi-auth-jwt。
我想使用钩子对一行执行访问控制,以便用户只能访问他们拥有的行。该钩子将添加一个额外的 where 子句以确保用户是该行的所有者(例如:WHERE ownerId=user.id)。
问题是,如何将用户 id 传递给 Sequelize,以便在钩子触发时钩子拥有它?我已经查看了文档,如果可能的话,这对我来说并不明显。
谢谢
嗨,我正在为DroidX编写一个480x854的应用程序.我按如下方式设置了AVD:
target:API level 7
skin:480x854
hw.lcd.density:160
而已.模拟器加载很好,看起来很棒,但我的应用程序由于某种原因没有fill_parent.看这里:
它不会一直向上扩展,我不知道为什么.这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@drawable/logo_recruiting"
android:background="#FF000000"
android:adjustViewBounds="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="30dip" />
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:background="@drawable/menu_background">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="25dip"
android:text="@string/events"
android:textColor="#FFFFFFFF"
android:textSize="22dip"
android:paddingBottom="5dip"
android:background="@drawable/events_button"
android:onClick="launchEventsMap"
android:id="@+id/events_button"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="25dip"
android:text="@string/jobs"
android:textColor="#FFFFFFFF"
android:textSize="22dip"
android:paddingBottom="5dip"
android:background="@drawable/jobs_button"
android:id="@+id/jobs_button"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="25dip"
android:text="@string/applicants"
android:textColor="#FFFFFFFF"
android:textSize="22dip"
android:paddingBottom="5dip"
android:background="@drawable/applicants_button"
android:id="@+id/applicants_button"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="25dip"
android:text="@string/resumes"
android:textColor="#FFFFFFFF"
android:textSize="22dip"
android:paddingBottom="5dip"
android:background="@drawable/resumes_button"
android:id="@+id/resumes_button"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="25dip" …
Run Code Online (Sandbox Code Playgroud) 在hapi.js API中,他们指定身份验证方案也可以返回工件作为凭证对象的一部分.
什么是身份验证工件以及它们为何有用?是否有一个很好的例子说明为什么hapi团队将其作为API的一部分?
我在节点中使用 babel 的require 钩子来利用 ES6,但我在 bluebird 承诺链中遇到了箭头函数的一些挑战。
我.bind({})
在我的承诺链的顶部使用一个空对象来创建共享状态,我可以在其中存储以前的值,直到我在链的下游需要它们为止。Bluebird 将这种用法解释为“有用的副目的”。
当我切换到箭头的功能,我不能再因为箭头函数使用词汇使用共享状态this
,其是undefined
在巴别(巴别在严格模式下自动运行)。
工作示例:https : //jsbin.com/veboco/edit?html,js,console
ES6 示例(不工作):https ://jsbin.com/menivu/edit?html,js,console
在这种情况下,有没有办法利用箭头函数?在我的代码中,我从一个对象方法中调用这些方法 - 不this
应该定义为调用该方法的对象吗?
hapijs ×3
android ×2
javascript ×2
babeljs ×1
bluebird ×1
ecmascript-6 ×1
jquery ×1
layout ×1
mongodb ×1
mongoose ×1
reactjs ×1
screen ×1
sequelize.js ×1
this ×1