zoukankan      html  css  js  c++  java
  • Build my first Blazor app

         While reading C# 8.0 recently, I came across an article about writing wasm. Here is an example of how to build Blazor.

        command prompt :dotnet new blazorserver -o BlazorApp --no-https  and cd BlazorApp ,and dotnet run

     Counter.razor

    @page "/counter"
    
    <PageTitle>Counter</PageTitle>
    
    <h1>Counter</h1>
    
    <p role="status">Current count: @currentCount</p>
    
    <button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
    
    @code {
        private int currentCount = 0;
    
        private void IncrementCount()
        {
            currentCount++;
        }
    }
    

    at index.rator:

    @page "/"
    
    <PageTitle>Counter</PageTitle>
    
    <h1>Hello, world!</h1>
    
    Welcome to your new app.
    
    <SurveyPrompt Title="How is Blazor working for you?" />
    
    <Counter />
    

    to change:

    @page "/counter"
    
    <PageTitle>Counter</PageTitle>
    
    <h1>Counter</h1>
    
    <p>Current count: @currentCount</p>
    
    <button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
    
    @code {
        private int currentCount = 0;
    
        [Parameter]
        public int IncrementAmount { get; set; } = 1;
    
        private void IncrementCount()
        {
            currentCount += IncrementAmount;
        }
    }
    

      

    @page "/"
    
    <h1>Hello, world!</h1>
    
    Welcome to your new app.
    
    <SurveyPrompt Title="How is Blazor working for you?" />
    
    <Counter IncrementAmount="10" />
    

    learn to :

    使用 Blazor 生成 Web 应用 - Learn | Microsoft Docs

     

     

    ,Best Wish 不负年华
  • 相关阅读:
    网站上线的过程
    PHP的四种基本算法
    YII框架第三方微博登录
    《正三角》《倒三角》
    PHP实现四种基本排序
    php实现快速排序
    iwebshop 简介
    收集的伪静态中经常使用的一些参数
    我与AI的相识
    phpstudy下的nginx服务器显示目录
  • 原文地址:https://www.cnblogs.com/shiningleo007/p/15671385.html
Copyright © 2011-2022 走看看