覆盖具有参数的js函数
Override js function which has arguments
我想覆盖有参数的js方法。
请检查原始js文件:bundle.js
Product.Bundle = Class.create();
Product.Bundle.prototype = {
reloadPrice: function() {
----- Default Code -----
},
selectionPrice: function(optionId, selectionId) {
----- Default Code -----
},
}
我必须在我的 js 文件中覆盖这两个方法。我可以在我的 js 中成功覆盖 reloadPrice 方法但不能覆盖 selectionPrice
方法。
请检查我的js文件代码,reloadPrice方法覆盖成功
<script>
Product.Bundle.prototype.reloadPrice =
Product.Bundle.prototype.reloadPrice.wrap(function(parentMethod) {
----- Default Code ------
});
// Doing same thnig for SelectionPrice method but not worked :
Product.Bundle.prototype.selectionPrice =
Product.Bundle.prototype.selectionPrice.wrap(function(parentMethod) {
----- Default Code -----
});
</script>
我在哪wrong.Please帮帮我
当您必须覆盖具有参数的方法时,您可以像下面那样覆盖它:
<script>
Product.Bundle.prototype.selectionPrice =
Product.Bundle.prototype.selectionPrice.wrap(function(parentMethod,optionId, selectionId) {
----- Default Code -----
});
</script>
我想覆盖有参数的js方法。
请检查原始js文件:bundle.js
Product.Bundle = Class.create();
Product.Bundle.prototype = {
reloadPrice: function() {
----- Default Code -----
},
selectionPrice: function(optionId, selectionId) {
----- Default Code -----
},
}
我必须在我的 js 文件中覆盖这两个方法。我可以在我的 js 中成功覆盖 reloadPrice 方法但不能覆盖 selectionPrice 方法。
请检查我的js文件代码,reloadPrice方法覆盖成功
<script>
Product.Bundle.prototype.reloadPrice =
Product.Bundle.prototype.reloadPrice.wrap(function(parentMethod) {
----- Default Code ------
});
// Doing same thnig for SelectionPrice method but not worked :
Product.Bundle.prototype.selectionPrice =
Product.Bundle.prototype.selectionPrice.wrap(function(parentMethod) {
----- Default Code -----
});
</script>
我在哪wrong.Please帮帮我
当您必须覆盖具有参数的方法时,您可以像下面那样覆盖它:
<script>
Product.Bundle.prototype.selectionPrice =
Product.Bundle.prototype.selectionPrice.wrap(function(parentMethod,optionId, selectionId) {
----- Default Code -----
});
</script>