覆盖 /_core/js/product.js 中的函数
Override functions in /_core/js/product.js
我需要在 /_core/js
下自定义 product.js
中的函数行为。函数声明为:
function replaceAddToCartSections(data) {}
我尝试在 custom.js
中创建一个同名函数。由于这是HTML中加载的最后一个js文件,我以为原来的功能会被覆盖,但结果不是这样。
当我在 Mozilla 开发工具中打印 replaceAddToCartSections.toString()
时,我得到了我的新函数。但是,当我从 custom.js
中删除函数时,我得到:
ReferenceError: replaceAddToCartSections is not defined
core.js
的函数是私有的吗?如何覆盖它们?与 Webpack 配置有关吗?
在 replaceAddToCartSections
被调用之后,updatedProduct
被发出,所以你可以定义一个像这样的函数:
prestashop.on('updatedProduct', function (event) {
// your code
})
我需要在 /_core/js
下自定义 product.js
中的函数行为。函数声明为:
function replaceAddToCartSections(data) {}
我尝试在 custom.js
中创建一个同名函数。由于这是HTML中加载的最后一个js文件,我以为原来的功能会被覆盖,但结果不是这样。
当我在 Mozilla 开发工具中打印 replaceAddToCartSections.toString()
时,我得到了我的新函数。但是,当我从 custom.js
中删除函数时,我得到:
ReferenceError: replaceAddToCartSections is not defined
core.js
的函数是私有的吗?如何覆盖它们?与 Webpack 配置有关吗?
在 replaceAddToCartSections
被调用之后,updatedProduct
被发出,所以你可以定义一个像这样的函数:
prestashop.on('updatedProduct', function (event) {
// your code
})