我知道有更好的模式,但在这种情况下,我们希望将一些遗留代码移到视图中。这个 html 有一个
<script src="binding.js"></script>
需要在页面呈现和显示后运行。
我希望用<script src="">标签来做到这一点,但标签似乎被剥离了。
我们如何获取要渲染的脚本标签,或者使用 durandal 解决问题?
示例 html:
<div>
    <link rel="stylesheet" href="/Content/stylesheet1.css"/>
    <link rel="stylesheet" href="/Content/stylesheet2.css"/>
    <header>
        <h1>heading</h1>
        <h2>sub heading</h2>
    </header>
    <section>
    </section>
    <footer>              
    </footer>
    <script src="dobinding.js"></script>    
</div>
这很有帮助:
http://knockoutjs.com/documentation/custom-bindings.html