javascript - avalon2操作dom后绑定失败的疑问

查看:76
本文介绍了javascript - avalon2操作dom后绑定失败的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<div class="test2" ms-controller="test2"></div>
<div id="kk">click</div>

<script type="text/javascript">
    $(".test").append("<p>{{@sex}}</p>");
        var s=avalon.define({
              $id: "test2",
              age: 23,
              card: "aaaa"
          });
          $(".test2").append("<p>{{@age}}</p>");
        $("#kk").click(function(){
            $(".test2").append("<p>{{@card}}</p>");
                      s.age++;
            avalon.scan(document.body);
        });
</script>

//事件前的的操作是可以的,为何事件中添加的p绑定是失败的

解决方案

<div class="test2" ms-controller="test2" ms-html="@html"></div>

var s=avalon.define({
              $id: "test2",
              age: 23,
              html: '<p>{{@sex}}</p>',
              card: "aaaa"
          });
          

这篇关于javascript - avalon2操作dom后绑定失败的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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