는 방법을 확장할 수 있습니다.js 다.html 파일에서 Magento2
-
28-09-2020 - |
문제
내장 customer address
이러한 나 수정/확장 vendor/Magento/module-ui
코어 파일이 있습니다.
i.e
root/vendor/magento/module-ui/view/base/web/js/form/components/collection.js
고
root/vendor/magento/module-ui/view/base/web/templates/form/components/collection.html
을 때 수 있도록 변경되었습 core 파일의 작동하지만 이것은 좋지 않 절차/아이디어를 확장할 수 있습니다.
그래서 내가 만들어 공급 업체 이름 Magento
에 root/app/code/
내가 배치된 위의 파일을 동일한 폴더에 로컬입니다.
i.e
root/app/code/magento/module-ui/view/base/web/js/form/components/collection.js
고
root/app/code/magento/module-ui/view/base/web/templates/form/components/collection.html
후에는 배치 해당 파일 내가 지워집니다.그러나 여전히 보이지 않는 나의 변경합니다.
나는 달 php bin/magento setup:static-content:deploy
명령도 하지만 행운입니다.
시안게 어떻게 하면 이렇게 할 수 있습니까?
해결책 2
마지막으로 달성입니다.
성 requirejs-config.js
에서 파일 학습/HelloWorld/보기/베이스 과를 붙여 아래 코드
var config = {
map: {
'*': {
'Magento_Ui/js/form/components/collection':'Learning_HelloWorld/js/form/components/collection'
}
}
};
성 collection.js
에서 파일 학습/HelloWorld/보기/기본/웹/js/양식/구성요소 과 복사본을 붙여 핵심 코드고 modyfie 니다.
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'underscore',
'mageUtils',
'uiRegistry',
'uiComponent',
'uiLayout',
'Magento_Ui/js/modal/confirm'
], function (_, utils, registry, Component, layout, confirm) {
'use strict';
var childTemplate = {
parent: '${ $.$data.name }',
name: '${ $.$data.childIndex }',
dataScope: '${ $.name }',
nodeTemplate: '${ $.$data.name }.${ $.$data.itemTemplate }'
};
return Component.extend({
defaults: {
lastIndex: 0,
template: 'Learning_HelloWorld/form/components/collection'
},
/* my custom methods */
sendAddress: function (elem) {
var self = this;
self._sendAddress(elem);
},
/* my custom methods */
_sendAddress: function (elem) {
this.bubble('update');
}
});
});
성 collection.html
에서 파일 학습/HelloWorld/보기/기본/웹/서식/양식/구성요소 경로를 붙여 핵심 코드 및 수정
<div class="ui-tabs">
<!-- My Extra html code -->
<button type="button" data-bind="click: $parent.sendAddress.bind($parent, element)">
Send this Address
</button>
</div>
지금 실행하여 아래의 명령입니다.
- 설정:업그레이드
- 설정:정적 컨텐츠 배포
지금 그것은 작동합니다.
게는 경우 쿼리를 처리합니다.
다른 팁
하나의 모듈이 등록에서 하나의 경로,그 이유는 그것을 읽을 수 있는 공급 업체,그러나 수 없는 응용 프로그램에서/코드입니다.