Aurelia不绑定innerHTML绑定语句 [英] Aurelia not binding innerHTML bind statements

查看:69
本文介绍了Aurelia不绑定innerHTML绑定语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于我已经使用innerhtml.bind插入了一些html,但是该html中包含它自己的aurelia'.bind'语句,您如何获得这些内部绑定以被aurelia识别?

Given I have used innerhtml.bind to insert some html but that html includes within it it's own aurelia '.bind' statements how do you get those inner bindings to be recognized by aurelia?

示例

<div innerhtml.bind="myhtml"></div>

其中

var myhtml = "<div click.trigger='console.log(123)'>some text</div>";

推荐答案

使用innerhtml属性进行绑定只会设置元素的 innerHTML属性.标记未通过Aurelia的 模板系统. 绑定表达式和require元素不会 被评估.

Binding using the innerhtml attribute simply sets the element's innerHTML property. The markup does not pass through Aurelia's templating system. Binding expressions and require elements will not be evaluated.

如何创建组件并使用插槽?

How about creating a component and use a slot?

my-component.html

<template>
    <div><slot></slot></div>
</template>

consumer.html

<require from="./my-component.html"></require>
<my-component><div click.trigger='console.log(123)'>some text</div></my-component>

这篇关于Aurelia不绑定innerHTML绑定语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆