小编Myl*_*ies的帖子

如何在 Blazor 中以两种方式绑定级联值?

我正在玩 Blazor 中的自定义模板,我试图找到一种方法来双向绑定 aCascadingValue或实现类似的东西。现在我有以下模板。

@if (PopupVisible)
{
    <DxPopup>
        <HeaderTemplate>
            <h4 class="modal-title">@HeaderText</h4>
            <button type="button" class="close" @onclick="@UpdatePopupVisible">&times;</button>
        </HeaderTemplate>
        <ChildContent>
            <div class="modal-body">
                <div class="container-fluid">
                  @bodyContent
                </div>
            </div>
            <div class="modal-footer">
                @footerContent
                <button class="btn btn-secondary" @onclick="UpdatePopupVisible">Cancel</button>
            </div>
        </ChildContent>
    </DxPopup>
}

@code {
    [CascadingParameter] public bool PopupVisible { get; set; }
    [CascadingParameter] public EventCallback<bool> PopupVisibleChanged { get; set; }

    [Parameter] public RenderFragment HeaderText { get; set; }
    [Parameter] public RenderFragment footerContent { get; set; }
    [Parameter] public RenderFragment bodyContent { get; set; }

    private …
Run Code Online (Sandbox Code Playgroud)

.net c# two-way-binding blazor blazor-server-side

5
推荐指数
1
解决办法
2579
查看次数

Haskell 解压折叠

我试图弄清楚如何使用自定义版本的 fold(基本上用作 foldl)在 Haskell 中创建自定义解压缩函数,但我被卡住了。我可以得到它

unzip' :: [(a,b)] -> ([a],[b])
unzip' = fold (\x->([x!!0],[x!!1])) ([],[])
Run Code Online (Sandbox Code Playgroud)

但这会出错:

• Couldn't match expected type ‘[a]’
              with actual type ‘(Integer, Integer)’
• In the first argument of ‘tail’, namely ‘(1, 2)’
  In the expression: tail (1, 2)
  In an equation for ‘it’: it = tail (1, 2)
• Relevant bindings include
    it :: [a] (bound at <interactive>:114:1)
Run Code Online (Sandbox Code Playgroud)

据我所知,x是,(1,2)但我不确定如何将其进一步拆分为 1 和 2。这是我正在使用的 fold 函数:

fold :: (a -> b -> b) …
Run Code Online (Sandbox Code Playgroud)

haskell unzip fold

1
推荐指数
1
解决办法
783
查看次数

标签 统计

.net ×1

blazor ×1

blazor-server-side ×1

c# ×1

fold ×1

haskell ×1

two-way-binding ×1

unzip ×1