工作解决方案
只需从下面的路径创建或编辑requirejs-config.js文件即可。
/app/code/Namespace/Module/view/frontend/requirejs-config.js
并将代码放置在requirejs-config.js中
var config = {
map: {
'*': {
'Magento_Payment/template/payment/cc-form.html':
'Namespace_Module/template/payment/cc-form.html'
}
}
};
所以我们可以用这种方式覆盖任何html文件。
类似:
我如何替换文件
vendor/magento/module-payment/view/frontend/web/template/payment/cc-form.html
在它用src加载的页面上
static/frontend/Magento/luma/en_US/Magento_Payment/template/payment/cc-form.html
所以它的RequireJS ID是
Magento_Payment/template/payment/cc-form.html
附注:内部UI组件的东西等于 Magento_Payment/payment/cc-form。单词“template”和“.html”会自动添加。
现在你可以通过RequireJS config替换这个应用程序文件
var config = {
"map": {
"*": {
"Magento_Payment/template/payment/cc-form.html":
"<OwnBrand>_<OwnModule>/template/payment/cc-form.html"
}
}
};
这段代码片段放置requirejs-config.js在你的模块中。就这些。
原文地址:https://magento.stackexchange.com/questions/116857/how-to-override-a-html-file-using-a-custom-module