如何使模板帮助者动态更改?骨干
我的视图中有一个模板助手方法:
templateHelpers() {
return {
url : this.model.get('url')
};
}
我在模板中使用了URL变量;但是,仅在按钮点击时分配URL;因此,当呈现视图时,URL变量最初是未定义的。我该如何做到这一点,以便当实际分配URL时,模板助手变量还会更新到更新的URL变量?
I have a template helpers method in my view like so:
templateHelpers() {
return {
url : this.model.get('url')
};
}
And I use the url variable in my template; However, the URL only gets assigned on button click; So when the view is rendered, the URL variable is initially undefined. How can I make it so that when the url is actually assigned, the template helper variable also updates to the updated url variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说仅在按钮单击上分配URL,并且您希望该模板助手在分配时更新到更新的URL。
因此,如果我正确理解您,则解决方案很简单:
You say that url is only assigned on button click and you want that template helper updates to the updated url when it is assigned.
So, the solution is simple if I understand you correctly: