我可以创建在其中使用子标记的非空 Knockout 组件吗?
一个示例是用于显示模式对话框的组件,例如:
<modal-dialog>
<h1>Are you sure you want to quit?</h1>
<p>All unsaved changes will be lost</p>
</modal-dialog>
其中与组件模板一起:
<div class="modal">
<header>
<button>X</button>
</header>
<section>
<!-- component child content somehow goes here -->
</section>
<footer>
<button>Cancel</button>
<button>Confirm</button>
</footer>
</div>
输出:
<div class="modal">
<header>
<button>X</button>
</header>
<section>
<h1>Are you sure you want to quit?</h1>
<p>All unsaved changes will be lost</p>
</section>
<footer>
<button>Cancel</button>
<button>Confirm</button>
</footer>
</div>