本文介绍了在Dart中的髭模板用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在test.dart文件中,将创建一个模板并填充如下:

  import'dart:html'; 
// IMPORT MUSTACHE FOR TEMPLATES
import'package:mustache / mustache.dart'as mustache;

function loadData()
{
//一些脚本.....
output = template.renderString({
'data_cell':[
{'event_title':TitleOne,'event_desc':Desc},]});
}



在test.html文件中,如何插入output以下的data_celldiv。

 < body& 
< p id =text>应用程式< / p>
< div class =row>
< div class =data_cell>
< / -  
< / - >
< / body>
< c $ c>


解决方案



  querySelector('div.data_cell')。appendHtml(output); 
  var nodeValidator = new NodeValidatorBuilder()
..allowHtml5你的需求
..allowElement('a',attributes:['href'])// - -
..allowElement('img',attributes:['src']); // - -
querySelector('div.data_cell')。append(new Element.html(output,validator:nodeValidator);

Fairly recent to web programming and all apologies for asking a basic question.

In the test.dart file, a template is created and populated as below

import 'dart:html';
// IMPORT MUSTACHE FOR TEMPLATES
import 'package:mustache/mustache.dart' as mustache;

function loadData()
{
 // some script .....
  output = template.renderString({
 'data_cell': [
     {'event_title': TitleOne,'event_desc' : Desc},]});
 }

In the test.html file, how can I insert the "output" in the below "data_cell" div.

<body>
<p id="text">Application</p>
<div class="row">
   <div class="data_cell">
        <!-- HOW TO INSERT "output" generated from DART script here" -->
   </div>
</body>
解决方案
querySelector('div.data_cell').appendHtml(output);

or

var nodeValidator = new NodeValidatorBuilder()
    ..allowHtml5()                            // according to your requirements
    ..allowElement('a', attributes: ['href']) // - " -
    ..allowElement('img', attributes: ['src']); // - " -
querySelector('div.data_cell').append(new Element.html(output, validator: nodeValidator);

这篇关于在Dart中的髭模板用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:34