如何通过单击按钮将另一个Razor组件加载到Razor组件中?

时间:2020-01-31 18:41:17

标签: c# asp.net-core blazor blazor-server-side matblazor

我只想在用户单击搜索按钮时将一个剃刀组件加载到另一个剃刀组件中,然后在用户单击“隐藏”按钮时将搜索剃刀组件(页面)显示到一个隐藏的div中,然后它将被隐藏。像嵌入式弹出窗口一样。

1 个答案:

答案 0 :(得分:2)

赞:

主要组件:

import os
from distutils.dir_util import copy_tree
import shutil
from os import path
import datetime

def main():
    src = "C:/Users/LT GM/Desktop/Python_files/"


    dst2 = "C:/Users/LT GM/Desktop/"
    for root,dirs,files in os.walk(src):
        for name in files:
            print("files: ",os.path.join(root,name))
        for name in dirs:
            copieddst = copy_tree(src,dst2)
            print("directory: ",os.path.join(root,name))
            print(" coppied directory :{0}".format(copieddst) )
    # make a duplicate of an existing file
        if path.exists(src):
    # get the path to the file in the current directory
            print("****")
            src = path.realpath("pandas.pdf")

    #seperate the path from the filter
        head, tail = path.split(src)
        print("path:" +head)
        print("file:" +tail)    
        dst =str(datetime.date.today()) + tail  
    # nowuse the shell to make a copy of the file
        shutil.copy(src, dst)

if __name__=="__main__":
    main()

@page "/test" <button @onclick="(() => ShowComponent = true)">Show</button> <button @onclick="(() => ShowComponent = false)">Hide</button> @if (ShowComponent) { <ShowHideComponent></ShowHideComponent> } @code { bool ShowComponent { get; set; } = false; }

ShowHideComponent.razor