【问题标题】:Adding HTML in Ionic modals在 Ionic 模式中添加 HTML
【发布时间】:2017-08-26 11:00:51
【问题描述】:

我正在使用以下 ionic 示例在 ionic 中创建模态:http://ionicframework.com/docs/components/#modals

我正在使用以下代码为每个模式输出我的内容:https://github.com/ionic-team/ionic-preview-app/blob/master/src/pages/modals/basic/pages.ts

如果不将 HTML 输出为纯文本,我将如何在以下代码中为我的一个项目输出 HTML?

name: 'Gollum',
        quote: 'Sneaky little hobbitses!',
        image: 'assets/img/avatar-gollum.jpg',
        items: [
          { title: 'Race', note: 'Hobbit' },
          { title: 'Culture', note: 'River Folk' },
          { title: 'Alter Ego', note: 'Smeagol' }
        ]

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    您可以在此代码中使用 HTML

    Like:这里我们在引号中使用了两个标签(段落和强标签)

    name: 'Gollum',
        quote: '<p><strong>Sneaky little hobbitses!</strong></p>',
        image: 'assets/img/avatar-gollum.jpg',
        items: [
          { title: 'Race', note: 'Hobbit' },
          { title: 'Culture', note: 'River Folk' },
          { title: 'Alter Ego', note: 'Smeagol' }
        ]
    

    你可以在没有 html 的情况下显示

    喜欢:

    <div class="item item-text-wrap" [innerHTML]="post.quote"></div>
    

    注意 - post 是一个存储以下数据的变量。

    输出会这样

    鬼鬼祟祟的小霍比特人!

    【讨论】:

    • 太棒了!完美运行!非常感谢!
    • 太棒了@Breon,你想要我的回答吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-26
    • 1970-01-01
    • 2019-10-08
    • 2017-09-14
    相关资源
    最近更新 更多