![](/img/trans.png)
[英]Calling C++ function from JavaScript script running in a web browser control
[英]Replace JavaScript function with bash script or c++ script on linux
大家好,
是否有人可以幫助我,我需要用bash腳本(這很好)或用c / c ++腳本替換我所有javascript文件中的錯誤bug的JavaScript函數,如果不可能的話,我想替換我的javascript文件中的以下代碼行:
FormGroupDirective.prototype._updateDomValue = function () {
var _this = this;
this.directives.forEach(function (dir) {
var /** @type {?} */ newCtrl = _this.form.get(dir.path);
if (dir._control !== newCtrl) {
cleanUpControl(dir._control, dir);
if (newCtrl && newCtrl instanceof FormControl) {
setUpControl(newCtrl, dir);
dir._control = newCtrl;
} else {
dir._control = null;
}
}
});
this.form._updateTreeValidity({ emitEvent: false });
};
使用以下代碼行:
FormGroupDirective.prototype._updateDomValue = function () {
var _this = this;
this.directives.forEach(function (dir) {
var /** @type {?} */ newCtrl = _this.form.get(dir.path);
if (dir._control !== newCtrl) {
cleanUpControl(dir._control, dir);
if (newCtrl && newCtrl instanceof FormControl) {
setUpControl(newCtrl, dir);
dir._control = newCtrl;
} else {
dir._control = null;
}
}
});
this.form._updateTreeValidity({ emitEvent: false });
};
謝謝
我設法做到了。 所以我想替換:
FormGroupDirective.prototype._updateDomValue = function () {
var _this = this;
this.directives.forEach(function (dir) {
var /** @type {?} */ newCtrl = _this.form.get(dir.path);
if (dir._control !== newCtrl) {
cleanUpControl(dir._control, dir);
if (newCtrl && newCtrl instanceof FormControl) {
setUpControl(newCtrl, dir);
dir._control = newCtrl;
} else {
dir._control = null;
}
}
});
this.form._updateTreeValidity({ emitEvent: false });
};
通過
FormGroupDirective.prototype._updateDomValue = function () {
var _this = this;
this.directives.forEach(function (dir) {
var newCtrl = _this.form.get(dir.path);
if (dir._control !== newCtrl) {
cleanUpControl(dir._control, dir,_this);
if (newCtrl && newCtrl instanceof FormControl) {
setUpControl(newCtrl, dir,_this);
dir._control = newCtrl;
} else {
dir._control = _this;
}
}
});
this.form._updateTreeValidity({ emitEvent: false });
};
我制作了一個腳本,該腳本替換了第一個單詞FormGroupDirective和最后一個單詞glowEvent之間的行:false 。
我的腳本替換:
以下腳本命令檢查所有js文件並進行替換:
find . -name '*.js'|xargs sed -i '/FormGroupDirective/,/emitEvent: false/ {s/cleanUpControl(dir._control, dir);/cleanUpControl(dir._control, dir,_this);/;s/setUpControl(newCtrl, dir);/setUpControl(newCtrl, dir,_this);/; s/dir._control = null;/dir._control = _this;/ }'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.