修改Ember组件中的方法

时间:2016-09-11 16:13:35

标签: ember.js discourse

Discourse我要修改方法using (var doc = WordprocessingDocument.Open(@"D:\FSoft_CV - ThangPQ.docx", true)) { Body body = doc.MainDocumentPart.Document.Body; //Get all paragraphs var lstParagrahps = body.Descendants<Paragraph>().ToList(); foreach (var para in lstParagrahps) { var subRuns = para.Descendants<Run>().ToList(); foreach (var run in subRuns) { var subRunProp = run.Descendants<RunProperties>().ToList().FirstOrDefault(); var newFont = new RunFonts(); newFont.Ascii = "Algerian"; newFont.EastAsia = "Algerian"; if (subRunProp != null) { var font = subRunProp.Descendants<RunFonts>().FirstOrDefault(); subRunProp.ReplaceChild<RunFonts>(newFont, font); } else { var tmpSubRunProp = new RunProperties(); tmpSubRunProp.AppendChild<RunFonts>(newFont); run.AppendChild<RunProperties>(tmpSubRunProp); } } } doc.MainDocumentPart.Document.Save(); doc.Close(); } 。修改代码将放在插件中。

此文件中的简短摘录:

_dock

如何修改此方法?我应该重新打开这个组件吗?它的语法是什么?

1 个答案:

答案 0 :(得分:1)

查看thisthis指南。 您需要创建一个新组件,如下所示:

// components/my-discourse-component.js
import MyDiscourseComponent from 'discourse/components/topic-progress';

MyDiscourseComponent.extend({
  // Here you can extend the function. Don't forget
  // this._super(...arguments) if you want to use the original function.
});

MyDiscourseComponent.reopenClass({
  // Here you can completly override the function.
});

export default MyDiscourseComponent;

并在你的temlate中使用{{my-discourse-component}}

或者您可以将插件的代码复制到mixin中,只需使用该mixin扩展新组件即可。