일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- .net maui
- mysql
- 알고리즘
- C++
- 도커
- 파이썬
- 탐색
- maui
- Docker
- REDIS
- asp.net
- 재귀
- .net core
- Merge Sort
- 정렬
- 백준
- dfs
- 스택
- BFS
- C#
- sql
- 시간복잡도
- 큐
- Get
- quick sort
- .NET
- 자료구조
- asp.net core
- docker-compose
- API
- Today
- Total
코젤브
[Blazor] 컴포넌트 소개 및 활용 본문
Blazor에 대해 설명한 글 : (아직 MD 형식으로 깃허브에만 정리해서 추후 블로그 글로 올릴 예정)
Button
BootStrap의 Button 컴포넌트로 사용 가능하다.
<button type="button" class="btn btn-primary btn-lg">Large button</button>

class에 사용할 버튼의 디자인을 지정할 수 있고 @onclick 속성으로 버튼 클릭 시 이루어질 행동을 함수로 지정할 수 있다
아래 공식 문서를 참고해서 디자인을 설정할 수 있다
https://getbootstrap.com/docs/5.3/components/buttons/
Buttons
Use Bootstrap’s custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
getbootstrap.com
Message
✨ 이때! 처음 Ant Design의 pop-up 기능을 사용한다면, 아래 설정을 먼저 따라하자! ✨ (아래 이어진다)
Ant Design의 Message 컴포넌트를 활용해 메세지 박스를 띄울 수 있다.
@inject IMessageService _message
<Button Type="default" OnClick="OnClick">
Customized display duration
</Button>
@code{
private void OnClick()
{
_message.Success("This is a prompt message for success, and it will disappear in 10 seconds", 10);
}
}

아래 공식 문서에 여러 메세지 박스들과 구체적인 사용 방법이 나와있다. (웹에서 테스트도 바로 가능하다)
https://antblazor.com/en-US/components/message
Ant Design Blazor
antblazor.com
✨ 이때! 처음 Ant Design의 pop-up 기능을 사용한다면, 아래 설정을 따라하자! ✨
To display the pop-up component dynamically, you need to add the <AntContainer /> component in App.razor.
- For Blazor WebApp, you also need to specify render mode to <Routes /> for interactivity.
<Routes @rendermode="RenderMode.InteractiveAuto" /> <-- specify the rendermode ✨
+ <AntContainer @rendermode="RenderMode.InteractiveAuto" /> <-- add this component ✨
- For legacy blazor apps just add a line of code:
<Router AppAssembly="@typeof(MainLayout).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<Result Status="404" />
</LayoutView>
</NotFound>
</Router>
<AntContainer /> <-- add this component ✨
Ant Design Blazor
antblazor.com
이렇게 App.razor 까지 수정 완료하면, 문제 없이 팝업이 작동하는 것을 알 수 있다!
'컴공의 일상 > C#' 카테고리의 다른 글
[Redis] 기본 명령어 (0) | 2024.07.19 |
---|---|
[Blazor] 외부 API 연동 시 HttpClient - CORS policy (0) | 2024.07.15 |
[Redis] Redis란? 설치 및 시작과 기본 명령어 (0) | 2024.07.10 |
[API Server] MVC 패턴과 Service, Repository (0) | 2024.07.09 |
C# [Required] vs required 차이점 (1) | 2024.04.22 |