我正在尝试使用/js/lib/stellar.jquery.js
中的插件:
var $ = require('jquery');
require('./lib/stellar.jquery')
$(function(){
$.stellar();
});
当我运行这个虽然我得到jQuery没有定义。我认为恒星jQuery插件是在jq库之前加载的。在stellar
插件的底部有以下代码:
...
// Expose the plugin class so it can be modified
window.Stellar = Plugin;
}(jQuery, this, document));
将“jQuery”更改为“$”也不起作用,给出“$ is not defined”
答案 0 :(得分:8)
无需指定依赖项的顺序。
因为jQuery和你的插件都不支持CommonJS模块,所以你需要对它们进行填充以使它们与browserify模块概念兼容。
npm install browserify-shim --save-dev
为你的package.json添加 jQuery 和你的插件的别名(可选,但推荐)
"browser":{
"customPlugin": "path/to/custom/plugin",
"jquery": "./node_modules/jquery/dist/jquery.js"
}
添加browserify shim转换以通过添加到package.json
来启用填充"browserify": {
"transform": [
"browserify-shim"
]
}
配置垫片
"browserify-shim": {
"jquery" : "jQuery",
"customPlugin" : { "depends": [ "jquery:jQuery" ] },
}
考虑一下,在冒号之前的依赖关系配置中,你应该指定文件名,而不是SHIMMED MODULE NAME !!! 冒号之后你应该指定标识符,这是你的模块在全局命名空间中所期望的。
然后,要求你的插件在使用前初始化它的代码
'use strict';
require('customPlugin');
var $ = require('jQuery');
$('.some-class-selector').myCustomPlugin();
答案 1 :(得分:6)
似乎another solution似乎要添加:
QSqlQuery q,q2;
for(int r=0; r<rowtablecount; r++){
q.prepare("update checkdata set "
"alobs=:alobs,"
"payee_name=:payee_name,"
"payee_nature=:payee_nature,"
"account_code=:account_code,"
"amount=:amount,"
"date_paid=:date_paid,"
"cancel_status=:cancel_status,"
"reviewer=:reviewer,"
"preparer=:preparer,"
"reciever=:reciever,"
"reviewer_pos=:reviewer_pos,"
"preparer_pos=:preparer_pos,"
"reciever_pos=:reciever_pos,"
"date_delivered=:date_delivered"
"where check_no = :checkno");
q.bindValue(":checkno", tabledata[r][2]);
qDebug() << tabledata[r][2];
q.bindValue(":alobs",tabledata[r][3]);
q.bindValue(":payee_name",tabledata[r][4]);
q.bindValue(":payee_nature",tabledata[r][5]);
q.bindValue(":account_code",tabledata[r][6]);
q.bindValue(":amount",tabledata[r][7].toDouble());
q.bindValue(":date_paid",tabledata[r][10]);
q.bindValue(":reviewer",reviewer);
q.bindValue(":preparer",preparer);
q.bindValue(":reciever",reciever);
q.bindValue(":reviewer_pos",reviewer_pos);
q.bindValue(":preparer_pos",preparer_pos);
q.bindValue(":reciever_pos",reciever_pos);
q.bindValue(":date_delivered",tabledata[r][9]);
q.bindValue(":acicn", acic_value);
q2.prepare("update acic set date_prepared=:date_prepared, total_amount=:total_amount where acic_num=:acic_num");
q2.bindValue(":date_prepared",tabledata[r][1]);
q2.bindValue(":total_amount",tabledata[r][8]);
q2.bindValue(":acic_num", acic_value);
if(!q.exec()){
if(q.lastError().isValid())
qDebug() << q.lastError().text() << " <error " << r;
QMessageBox::critical(this,tr("Error: Entry Failed"),tr("Data Field incorrect."));
if(!q2.exec()){
if(q2.lastError().isValid())
qDebug() << q2.lastError().text() << " <error " << r;
QMessageBox::critical(this,tr("Error: Entry Failed"),tr("Data Field incorrect."));