gpt4 book ai didi

javascript - 如何在其模板中使用 View 属性?

转载 作者:行者123 更新时间:2023-12-03 10:25:45 24 4
gpt4 key购买 nike

App.FolderListItemView = Ember.View.extend({
templateName: 'folder-list-item',
tagName: 'li',
classNames: ['folder'],
classNameBindings: ['opened'],
opened: false,
click: function (e) {
this.set('opened', !this.get('opened'));
}
});



<script type="text/x-handlebars" data-template-name="folder-list-item">
<i {{bind-attr class="opened:icon-content-plus:icon-content-minus"}}></i>
...
</script>

我想根据 View 的“打开”值更改图标(加号/减号)。

绑定(bind)属性不起作用。我该如何处理这个问题?

最佳答案

您需要在模板中使用view.opened属性

<script type="text/x-handlebars" data-template-name="folder-list-item">
<i {{bind-attr class="view.opened:icon-content-plus:icon-content-minus"}}></i>
...
</script>

关于javascript - 如何在其模板中使用 View 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29408192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com