当前位置:网站首页>Blazor University (36) component library
Blazor University (36) component library
2022-07-18 12:05:00 【Dotnet cross platform】
Link to the original text :https://blazor-university.com/component-libraries/
Component library
The component library enables us to integrate components and pages as well as any supporting files ( for example CSS file 、JavaScript And images ) Package into a reusable project .
Create a file called ClassLibraryConsumer The new Blazor Solution . Right click the solution and select Add->New Project, And then choose Razor Class Library – I'm going to call it BlazorUniversity.ClassLibrary.
This will be in the name of BlazorUniversity.ClassLibrary Create a new folder in the new folder Razor Class library , And create a new with the same name csproj file . Add the new library to the current solution , And then from ClassLibraryConsumer Reference the new library in the project .
Our new class library can now be used from any number of projects by including it in the solution and referencing it , Or you can push it to NuGet.org And as a NuGet Package usage .
Add supporting files
The default project created for us has a name wwwroot Folder . This is where we want to place any supporting documents needed by users of our library , for example JavaScript etc. .
Access the resources in the used component library
Of the component library used wwwroot The resources in the folder will be automatically published with your project . To access resources from the library used , We need to use the following URL Format .
/_content/PackageId/MyImage.png
_contentIt is part of the final path of all used component library resources .PackageIdIs a package containing binary files of resources ID. This is when you right-click the class library 、 When selecting properties and selecting the package tab, in the package ID Enter the name you see in . If you pass NuGet Installation Library , Then it is the name of the package you installed .MyImage.pngIt's from the component librarywwwrootThe name of any resource in the folder . Resources can be located directly in this folder , Or the path can identify resources in subfolders at any level , for example/_content/BlazorUniversity.ConsumedLibrary/scripts/HelloWorld.js
Please note that , Any component in our component library should also reference resources in the same format .
Use component library
Using the component library is very simple
Add a project reference to the Library
perhaps ,
Add to Library NuGet quote .
Be sure to read any comments from the library author , Because you may need to CSS and / or JavaScript Reference added to HTML.
On the client side Blazor The script used in the reference
On the client side Blazor In the application , This usually involves wwwroot/index.html File to add <script> quote .
On the server side Blazor The script used in the reference
For the server side Blazor Applications , It is added to the file /Pages/_Host.cshtml in , And it is usually quoted _framework/blazor.server.js or _framework/blazor.webassembly.js Existing <script> Add before marking
边栏推荐
- Pule frog 4d5d dynamic cinema | VR space travel equipment | VR takes you to travel in space
- 为什么说大公司不是天堂,里面有哪些坑?
- 总结下 i ++和++ i区别
- Analysis of websocket hijacking
- [speech enhancement] adaptive wavelet speech signal denoising based on MATLAB multi-dimensional spectrum [including Matlab source code, 1972]
- Blazor University (36)组件库
- The distant savior obeys the objective law (IV) -- cultural attribute
- Unity-NGUI的Prefab迁移到其他工程时脚本丢失解决办法
- Résolution du format d'image
- Redis overview, installation and visual access
猜你喜欢

DDD Domain Driven Design

Overview of database system -- overview of data model

Jsd-2204-mvc-weibo project-day15

Gao fushuai in unit testing, pytest framework (end) test report

Traditional gyms are trapped in large-scale, and Lexus sports "s2b2c" mode is the reference answer?

Surpass traditional giants and take the top place in the list of senior engineers! What does this local enterprise rely on?

【Jailhouse 文章】Bao: A Lightweight Static Partitioning Hypervisor for Modern Multi-Core Embedded...

IC classification of speech chip and comparison and selection of OTP speech chip of sop8

When Scala reads the input content in the command-line environment, the input content does not display the problem (unresolved)

一道极限题目
随机推荐
Common audio features: Mel spectrum, amplitude spectrum (short time Fourier transform spectrum /stft), Mel cepstrum (MFCC)
Interviewer: how can you close an order without using a scheduled task?
洛谷题单-高精度
MySQL JSON field query
数据库定时备份linux篇
uniapp uni-popup change
Free SSL certificate application and deployment practice
Pdf manual | 1666 pages zabbix6.0 official Chinese operation manual pdf free!
Transfer learning model training I
磁盘上的无刷电机改造
Wireless communication safety operation 4
The Sandbox Alpha 第三季首支预告片
2022年成都/杭州/厦门/武汉产品经理认证招生简章(NPDP)
常用音频特征:梅尔频谱(melspectrogram)、幅度谱(短时傅里叶变换谱/STFT)、梅尔倒谱(MFCC)
Kettle【实践 02】txt类型文件分类导入后执行SQL进行数据类型转换并入库(完整流程实例云资源分享:包含sql+kjb+ktr+测试文件)
Power BI----到底什么是度量值?
UE4_UE5播放音频(播放、停止功能)(附工程)
解决 : ReferenceError: PubSub is not defined
GDB or delve debug Go program, check variable display < optimized out > solution
Completion report of communication software development and Application