Skip to content

Razor compiler Unclosed div within @if #24907

@srxqds

Description

@srxqds

I place the razor code in if statement, but it is error:
image

all my code:

@inherits HubComponent
@if (Visible)
{
    <div style="position: absolute; z-index: 100; width: 400px; height: 200px;">
        <Row Style="cursor: move;">
            <Button Type="close" OnClick="OnCloseButtonClicked"></Button>
            <span>资源管理器</span>
        </Row>
        <Row>
            <Col>
                <FileTree></FileTree>
            </Col>
            <Col>
                <FileDetail></FileDetail>
            </Col>
        </Row>
    </div>
}

@code 
{   
    private bool visible = true;
    private bool draggable = true;
    [Parameter]
    public bool Draggable
    {
        get
        {
            return draggable;
        }
        set
        {
            draggable = value;
        }
    }

    [Parameter]
    public bool Visible
    {
        get
        {
            return visible;
        }
        set
        {
            if (visible != value)
            {
                visible = value;
                this.StateHasChanged();
            }
        }
    }

    private void OnCloseButtonClicked(MouseEventArgs args)
    {
        this.Visible = false;
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions