我对CommonJS,AMD和RequireJS仍感到非常困惑.即使阅读了很多.
我知道CommonJS(以前称为ServerJS)是一个用于在浏览器外部使用语言时定义一些JavaScript规范(即模块)的组.CommonJS模块规范有一些像Node.js或RingoJS的实现,对吧?
CommonJS,异步模块定义(AMD)和RequireJS之间有什么关系?RequireJS是CommonJS模块定义的实现吗?如果是的话,那么什么是AMD呢?
我读过,当在git中重命名文件时,你应该提交任何更改,执行重命名,然后暂存重命名的文件.Git将从内容中识别文件,而不是将其视为新的未跟踪文件,并保留更改历史记录.
然而,今晚这样做我最终还是回归git mv.
> $ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.html
#
Run Code Online (Sandbox Code Playgroud)
将Finder中的样式表重命名iphone.css为mobile.css
> $ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.html
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be …Run Code Online (Sandbox Code Playgroud) 我正在使用Node和Express创建一个应用程序.但是,我可以看到很快就很难管理放在里面的所有路线app.js.我已将所有模型放在子目录中/models.
这是我的app当前结构:
app.js
models
-- products
-- customers
-- ...
public
views
node_modules
Run Code Online (Sandbox Code Playgroud)
在app.js:
var express = require('express'),
routes = require('./routes'),
user = require('./routes/user'),
http = require('http'),
path = require('path'),
EmployeeProvider = require('./models/employeeprovider').EmployeeProvider,
Products = require('./models/products').Products,
Orders = require('./models/orders').Orders,
Customers = require('./models/customers').Customers,
checkAuth = function(req, res, next) {
if (!req.session.user_id) {
res.send('You are not authorized to view this page');
} else {
next();
}
};
var app = express();
Run Code Online (Sandbox Code Playgroud)
然后一些配置一样port,views目录,渲染引擎等. …
我有一个带有三个过滤器的打开文件对话框:
QString fileName = QFileDialog::getOpenFileName(
this,
title,
directory,
tr("JPEG (*.jpg *.jpeg);; TIFF (*.tif);; All files (*.*)")
);
Run Code Online (Sandbox Code Playgroud)
这将显示一个对话框,其中"JPEG"被选为默认过滤器.我想按字母顺序放置过滤器列表,因此"所有文件"在列表中排在第一位.但是,如果我这样做,"所有文件"是默认选择的过滤器 - 我不想要.
我可以为此对话框设置默认选定的过滤器,还是必须使用第一个指定的过滤器?
我尝试指定第5个参数(QString)来设置默认选择的过滤器,但这不起作用.我认为这可能只用于检索用户设置的过滤器.
我阅读了其他PHPUnit安装问题,但没有取得任何成功.我的PEAR安装发生了什么?
$ sudo pear update-channels
Updating channel "components.ez.no"
Channel "components.ez.no" is up to date
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pear.phpunit.de"
Channel "pear.phpunit.de" is up to date
Updating channel "pear.symfony-project.com"
Channel "pear.symfony-project.com" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
$ sudo pear upgrade pear
Nothing to upgrade
$ sudo pear install phpunit/PHPUnit
phpunit/PHPUnit requires PEAR Installer (version >= 1.9.2), installed …Run Code Online (Sandbox Code Playgroud) 我不知道如何isLoading从reducerForm.jsreducer中访问一个布尔标志reducerRegister.js.我已经使用过combineReducers(),我isLoading在表单提交过程中用来禁用按钮.
它的初始状态为false,点击提交后,它会变为true.表单提交成功后,再次isLoading重置false.以下是此问题的相关代码:
actionRegister.js
let _registerUserFailure = (payload) => {
return {
type: types.SAVE_USER_FAILURE,
payload
};
};
let _registerUserSuccess = (payload) => {
return {
type: types.SAVE_USER_SUCCESS,
payload,
is_Active: 0,
isLoading:true
};
};
let _hideNotification = (payload) => {
return {
type: types.HIDE_NOTIFICATION,
payload: ''
};
};
// asynchronous helpers
export function registerUser({ // use redux-thunk for asynchronous dispatch
timezone,
password,
passwordConfirmation,
email,
name
}) …Run Code Online (Sandbox Code Playgroud) 我在这里看到了另一个关于在Greasemonkey中加载jQuery的问题.尝试了这个方法后,在我的==UserScript==标签中使用了这个require语句:
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
Run Code Online (Sandbox Code Playgroud)
我仍然在Firefox的错误控制台中收到以下错误消息:
Error: Component is not available
Source File: file:///Users/greg/Library/Application%20Support/
Firefox/Profiles/xo9xhovo.default/gm_scripts/myscript/jquerymin.js
Line: 36
Run Code Online (Sandbox Code Playgroud)
这会阻止我的greasemonkey代码运行.我确保@require在安装之前包含了for jQuery并保存了我的js文件,因为只在安装时加载了所需的文件.
码:
// ==UserScript==
// @name My Script
// @namespace http://www.google.com
// @description My test script
// @include http://www.google.com
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
GM_log("Hello");
Run Code Online (Sandbox Code Playgroud)
我在我的Macbook Pro,Leopard(10.5.8)上的Firefox 3.5.7上安装了Greasemonkey 0.8.20091209.4.我已经清除了我的缓存(除了cookie)并禁用了除Flashblock 1.5.11.2,Web Developer 1.1.8和Adblock Plus 1.1.3之外的所有其他插件.
我config.xml安装了我的Greasemonkey脚本:
<UserScriptConfig>
<Script filename="myscript.user.js" name="My Script"
namespace="http://www.google.com" description="My test script" enabled="true"
basedir="myscript">
<Include>http://www.google.com</Include>
<Require filename="jquerymin.js"/>
</Script>
Run Code Online (Sandbox Code Playgroud)
我可以看到jquerymin.js坐在 …
我有一个使用passthru()来运行命令的脚本.我需要在运行此命令之前设置一些shell环境变量,否则将无法找到它的库.
我尝试过以下方法:
putenv("LD_LIBRARY_PATH=/path/to/lib");
passthru($cmd);
Run Code Online (Sandbox Code Playgroud)
使用putenv()似乎不会传播到我正在运行的命令.它无法说它找不到它的库.当我export LD_LIBRARY_PATH=/path/to/lib在bash中运行时,它运行正常.
我也试过以下(徒劳):
exec("export LD_LIBRARY_PATH=/path/to/lib");
passthru($cmd);
Run Code Online (Sandbox Code Playgroud)
如何从PHP设置一个shell变量,它传播到我的PHP脚本的子进程?
我是否仅限于检查当前环境中是否存在变量并要求用户手动设置它?
嗨,我正在PhoneGap通过命令行界面.
我能够创建一个项目,并从Windows 7中的命令提示符运行Android模拟器.
由于我在eclipse中将项目导入并复制到我的工作区,因此在主类中显示了一些扩展的错误CordovaActivity.
错误是:
"CordovaActivity cannot be resolved to a type".
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我试图使用React refs在安装时聚焦Redux-Form字段.
当我尝试this.refs.title.getRenderedComponent().focus()时componentDidMount,会抛出一个错误:
edit_fund.js:77 Uncaught TypeError: Cannot read property 'getRenderedComponent' of undefined
当我在console.log this.refs中时,它主要是一个空对象,有时将'title'标识为ref,但它不可靠.
我错误地使用了refs吗?我的代码在下面供参考.
componentDidMount = () => {
this.refs.title
.getRenderedComponent()
.focus();
}
Run Code Online (Sandbox Code Playgroud)
...
<Field
id="title"
name="title"
component={FormInput}
type="text"
ref="title" withRef
/>
Run Code Online (Sandbox Code Playgroud)