【问题标题】:How to change Element innerHtml to Dart SDK 0.7.1如何将 Element innerHtml 更改为 Dart SDK 0.7.1
【发布时间】:2013-09-10 01:20:32
【问题描述】:

我正在使用飞镖消息https://github.com/mkozhukh/dart-message。它有功能 ...

MessageBox(String text, String header, String css){
    _box = new DivElement();
    ...
    _box.onClick.listen(_clickHandler);

    if (header != null)
      html.write("<div class='dhtmlx_popup_title'>$header</div>");
    html.write("<div class='dhtmlx_popup_text'><span>$text</span></div>");
    html.write("<div class='dhtmlx_popup_controls'>");
  }

String addButton(String text, String result){
    if (html != null){
      html.write("<div class='dhtmlx_popup_button' result='$result' ><div>$text</div></div>");
    } else
      throw new Exception(".addButton must be used before .show"); 
  }

 _clickHandler(Event event){
    String result = event.target.attributes["result"];
    if (result == null)
      result = event.target.parent.attributes["result"];
    hide(result); //<=== ERROR result alway return null
  }

还有

Future<String> show(){
    if (html != null){
      //finalize html initialization
      html.write("</div>");
      _box.innerHtml = html.toString();  //<===== ERROR after line : Removing disallowed attribute <DIV result="ok">
      html = null;
    }
...
}

...

如何将此代码更改为 SDK 0.7.1。 非常感谢。

【问题讨论】:

    标签: dart dart-webui


    【解决方案1】:

    我改了代码

    _box.innerHtml = html.toString();
    

    ==>

    _box.setInnerHtml(html.toString(), treeSanitizer : new NullTreeSanitizer());
    

    它工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 2019-05-17
      • 1970-01-01
      • 2016-01-02
      • 2019-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多