!1680 doc(#I43STU): add sample code of update Markdown content by call async method

* doc: 增加异步加载数据示例
This commit is contained in:
Argo 2021-08-04 02:30:04 +00:00
parent e1fb947782
commit 1834c12809
2 changed files with 14 additions and 0 deletions

View File

@ -52,6 +52,11 @@
</div>
</Block>
<Block Title="异步加载数据" Introduction="通过 <code>Webapi</code> 获得 <code>Markdown</code> 显示内容">
<Button Text="加载" IsAsync="true" OnClick="GetAsyncString" Icon="fa fa-fa" />
<Markdown @bind-Value="@AsyncValue"></Markdown>
</Block>
<Block Title="常用属性" Introduction="更改默认参数">
<p>设置 <code>Markdown</code> 编辑器最小高度 <code>300px</code>,默认高度 <code>500px</code>,提示信息这是 <code>Markdown</code><code>Tab</code> 方式显示,默认显示所见即所得页面</p>
<Markdown Height="500" MinHeight="300" Placeholder="这是 Markdown" PreviewStyle="PreviewStyle.Tab" InitialEditType="InitialEditType.Wysiwyg" Language="@Language"></Markdown>

View File

@ -3,6 +3,7 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Shared.Common;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
@ -25,6 +26,8 @@ namespace BootstrapBlazor.Shared.Pages
private string? Language { get; set; }
private string? AsyncValue { get; set; }
/// <summary>
/// OnInitializedAsync 方法
/// </summary>
@ -36,6 +39,12 @@ namespace BootstrapBlazor.Shared.Pages
Version = await VersionManager.GetVersionAsync("bootstrapblazor.markdown");
}
private async Task GetAsyncString()
{
await Task.Delay(600);
AsyncValue = $"### {DateTime.Now}";
}
private static IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
{
new AttributeItem(){