6
在這種情況下看看:如何訪問Knockout組件中的自定義元素?
ko.components.register('hello', {
viewModel: function() { },
template: "<h1>hello wrold</h1>"
});
如果我使用<hello></hello>
生成的HTML結果將是:
<hello><h1>hello world</h1></hello>
但如果我想這樣的:
<hello class="hello"><h1>hello world</h1></hello>
那麼如何我可以在組件中獲得對自定義元素標記的引用嗎?