gpt4 book ai didi

javascript - 覆盖/_core/js/product.js中的函数

转载 作者:行者123 更新时间:2023-12-02 22:21:51 25 4
gpt4 key购买 nike

我需要在 /_core/js 下的 product.js 中自定义函数的行为。函数声明为:

function replaceAddToCartSections(data) {}

我尝试在 custom.js 中创建一个同名的函数。由于这是 HTML 中加载的最后一个 js 文件,因此我认为原始函数会被覆盖,但结果并非如此。

当我在 Mozilla 开发工具中打印 replaceAddToCartSections.toString() 时,我得到了新函数。但是,当我从 custom.js 中删除该函数时,我得到:

ReferenceError: replaceAddToCartSections is not defined

core.js 的函数是私有(private)的吗?如何覆盖它们?与 Webpack 配置有关吗?

最佳答案

调用 replaceAddToCartSections 后,会发出 updatedProduct,因此您可以定义如下函数:

prestashop.on('updatedProduct', function (event) {
// your code
})

关于javascript - 覆盖/_core/js/product.js中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59202907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com