gpt4 book ai didi

Jquery knockout -在模板内定义变量

转载 作者:行者123 更新时间:2023-12-01 00:23:31 26 4
gpt4 key购买 nike

我有一个 knockout 模板,我想在其中定义一个本地参数(这是函数的结果),并在模板内使用它。

<script type="text/html" id="suggestedEmail-template">
{{ var customVariable = processResult($data); }}
<li>
<span data-bind="text: emailValue, attr: { 'data-customValue': customVariable }"></span>
</li>
</script>

可能吗?

最佳答案

您可以执行以下操作:

<script type="text/html" id="suggestedEmail-template">
<!-- ko if: customVariable = processResult($data) -->
<li>
<span data-bind="text: emailValue, attr: { 'data-customValue': customVariable }"></span>
</li>
<!-- /ko -->
</script>

关于Jquery knockout -在模板内定义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15210966/

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