如何使用C#在ASP.NET Core中轻松实现QRCoder
by Yogi
由瑜伽士
如何使用C#在ASP.NET Core中轻松实现QRCoder (How to easily implement QRCoder in ASP.NET Core using C#)
QRCoder is a very popular QR Code implementation library written in C#. It is available in GitHub. Here I am going to implement the QRCoder library to generate QR Codes in my ASP.NET Core application. I will also be using C#.
QRCoder是使用C#编写的非常流行的QR Code实现库。 它在GitHub中可用 。 在这里,我将实现QRCoder库以在我的ASP.NET Core应用程序中生成QR代码。 我还将使用C#。
I will implement QRCoder in 3 ways, which are:
我将以3种方式实现QRCoder:
1. Create QR Code Bitmap image for any text.
1.为任何文本创建QR码位图图像。
2. Create QR Code File (.qrr) for any text and then save these files in the application.
2.为任何文本创建QR码文件(.qrr),然后将这些文件保存在应用程序中。
3. Read and display all the QR Code Files (.qrr).
3.阅读并显示所有QR码文件(.qrr)。
Let’s start with the Installation of QRCoder in ASP.NET Core Framework.
让我们开始在ASP.NET Core Framework中安装QRCoder。
You can download the full code from my GitHub Respositiory.
您可以从我的GitHub Repositiory下载完整的代码 。
安装 (Installation)
Install QRCoder via NuGet Package Manager. If you want to use NuGet, just search for “QRCoder” or run the following command in the NuGet Package Manager console:
通过NuGet软件包管理器安装QRCoder。 如果要使用NuGet,只需搜索“ QRCoder”或在NuGet软件包管理器控制台中运行以下命令:
PM> Install-Package QRCoder
PM> Install-Package QRCoder
The QRCoder will install in 1 minute and will be ready to use.
QRCoder将在1分钟内安装好并可以使用。
Now let us start with the implementation of QRCoder in the 3 ways mentioned above.
现在让我们从上述3种方式开始QRCoder的实现。
为任何文本创建QR码位图图像 (Create QR Code Bitmap image for any text)
Create a new Controller called ‘QRCoderController
’ inside the Controllers folder. The controller will be created and it will have just one Action Method called ‘Index
’ in it:
在Controllers文件夹中创建一个名为“ QRCoderController
”的新Controller。 控制器将被创建,并且其中只有一个名为“ Index
”的操作方法:
public IActionResult Index()
{return View();
}
Import the following namespaces in the controller:
在控制器中导入以下名称空间:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using QRCoder;
Next, add the Index Action of type [HttpPost]
to the controller:
接下来,将类型为[HttpPost]
的Index Action添加到控制器:
[HttpPost]
public IActionResult Index(string qrText)
{QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText,QRCodeGenerator.ECCLevel.Q);QRCode qrCode = new QRCode(qrCodeData);Bitmap qrCodeImage = qrCode.GetGraphic(20);return View(BitmapToBytes(qrCodeImage));
}
This Index Action receives a string parameter called ‘qrText’. It contains the text that is provided by an Input control defined in the View. This text will be converted to QR Code Bitmap image. The following code lines do this work:
该索引操作接收一个名为“ qrText”的字符串参数。 它包含由视图中定义的输入控件提供的文本。 此文本将转换为QR码位图图像。 以下代码行可以完成这项工作:
QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q);QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
The QRCode object (‘qrCode
’) defined calls a static function called ‘BitmapToBytes()
’. The role of this function is to convert the Bitmap image to ‘Byte[]
’.
定义的QRCode对象(“ qrCode
”)调用一个名为“ BitmapToBytes()
”的静态函数。 该功能的作用是将位图图像转换为“ Byte[]
”。
Add this function to your controller:
将此功能添加到您的控制器:
private static Byte[] BitmapToBytes(Bitmap img)
{using (MemoryStream stream = new MemoryStream()){img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);return stream.ToArray();}
}
Finally create the Index View inside the ‘Views/QRCoder
’ folder with the following code:
最后,使用以下代码在“ Views/QRCoder
”文件夹内创建索引视图:
@model Byte[]
@{Layout = null;
}<!DOCTYPE html>
<html><head><meta name="viewport" content="width=device-width" /><title>Implementing QRCoder in ASP.NET Core - Create QR Code</title><style>body {background: #111 no-repeat;background-image: -webkit-gradient(radial, 50% 0, 150, 50% 0, 300, from(#444), to(#111));}h1,h2,h3 {text-align: center;color: #FFF;margin: 5px 0;}h1 {font-size: 30px;}h2 a {font-size: 25px;color: #0184e3;text-decoration: none;}h3 {font-size: 23px;border-bottom: solid 3px #CCC;padding-bottom: 10px;}h3 a {color: #00e8ff;text-decoration: none;}h3 a:hover,h2 a:hover {text-decoration: underline;}.container {width: 800px;margin: auto;color: #FFF;font-size: 25px;}.container #content {border: dashed 2px #CCC;padding: 10px;}#reset {padding: 5px 10px;background: #4CAF50;border: none;color: #FFF;cursor: pointer;}#reset:hover {color: #4CAF50;background: #FFF;}#viewContent table {width: 100%;}#viewContent table tr {height: 80px;background: darkcyan;}#viewContent table tr td {width: 50%;padding-left: 5px;}</style>
</head><body><div class="container"><div id="content"><h1>Implementing QRCoder in ASP.NET Core - Create QR Code</h1><h2><a href="http://www.yogihosting.com/category/aspnet-core/">Read the tutorial on YogiHosting » </a><button id="reset" onclick="location=''">Reset »</button></h2><div id="viewContent">@using (Html.BeginForm(null, null, FormMethod.Post)) {<table><tbody><tr><td><label>Enter text for creating QR Code</label</td><td><input type="text" name="qrText" /></td></tr><tr><td colspan="2"><button>Submit</button></td></tr></tbody></table>}</div>@{if (Model != null){<h3>QR Code Successfully Generated</h3><img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(Model))" />}}</div></div>
</body>
</html>
The Index View has an ‘input
’ control. The user enters their text into this control to create the QR Code:
索引视图具有“ input
”控件。 用户将其文本输入此控件以创建QR码:
<input type="text" name="qrText"
/>
<input type="text" name="qrText"
/>
Once the QR Code is generated by the Index Action method, its ‘byte
’ array is returned to the View as model and then the bitmap image is displayed by the below code:
通过Index Action方法生成QR代码后,其“ byte
”数组将作为模型返回到View,然后通过以下代码显示位图图像:
@{if (Model != null){<h3>QR Code Successfully Generated</h3><img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(Model))" />}
}
测试代码 (Testing the Code)
Run your application and go to the URL — ‘http://localhost:50755/QRCoder
’ to invoke the Index Action method.
运行您的应用程序并转到URL http://localhost:50755/QRCoder
'以调用Index Action方法。
In the text box, add your text and click the submit button to create the QR Code Bitmap image.
在文本框中,添加文本,然后单击提交按钮以创建QR码位图图像。
See this image which illustrates it working:
请参阅此图片,说明其工作原理:
为任何文本创建QR码文件(.qrr),然后将这些文件保存在应用程序中 (Create QR Code File (.qrr) for any text and then save these files in the application)
You can also generate QR Code files for a text and save it in your website. These files have .qrr extension.
您还可以为文本生成QR Code文件,并将其保存在您的网站中。 这些文件有。 qrr扩展名。
To your controller add the following Action methods called ‘GenerateFile
’:
向您的控制器添加以下名为“ GenerateFile
”的Action方法:
public IActionResult GenerateFile()
{return View();
}[HttpPost]
public IActionResult GenerateFile(string qrText)
{QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q);string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);qrCodeData.SaveRawData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed);QRCodeData qrCodeData1 = new QRCodeData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed);QRCode qrCode = new QRCode(qrCodeData1);Bitmap qrCodeImage = qrCode.GetGraphic(20);return View(BitmapToBytes(qrCodeImage));
}
The [HttpPost]
version of this action method generates the QR Code files inside the ‘wwwroot/qrr
’ folder. The code that does this work is the following:
此操作方法的[HttpPost]
版本在' wwwroot/qrr
'文件夹内生成QR Code文件。 可以完成此工作的代码如下:
QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q);string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);qrCodeData.SaveRawData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed);
Once the .qrr file is created then I am simply reading it for its saved location in the website. Then I am converting it to Bitmap type and finally sending the image’s bytes to the view. The corresponding code is:
创建.qrr文件后,我只是在阅读该文件以了解其在网站中的保存位置。 然后,我将其转换为Bitmap类型,最后将图像的字节发送到视图。 相应的代码是:
QRCodeData qrCodeData1 = new QRCodeData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed);QRCode qrCode = new QRCode(qrCodeData1);
Bitmap qrCodeImage = qrCode.GetGraphic(20);return View(BitmapToBytes(qrCodeImage));
Next, add the GenerateFile view inside the ‘Views/QRCoder
’ folder and add the following code to it:
接下来,在“ Views/QRCoder
”文件夹内添加GenerateFile视图,并向其中添加以下代码:
@model Byte[]
@{Layout = null;
}<!DOCTYPE html>
<html><head><meta name="viewport" content="width=device-width" /><title>Implementing QRCoder in ASP.NET Core - Create QR Code File</title><style>body {background: #111 no-repeat;background-image: -webkit-gradient(radial, 50% 0, 150, 50% 0, 300, from(#444), to(#111));}h1,h2,h3 {text-align: center;color: #FFF;margin: 5px 0;}h1 {font-size: 30px;}h2 a {font-size: 25px;color: #0184e3;text-decoration: none;}h3 {font-size: 23px;border-bottom: solid 3px #CCC;padding-bottom: 10px;}h3 a {color: #00e8ff;text-decoration: none;}h3 a:hover,h2 a:hover {text-decoration: underline;}.container {width: 800px;margin: auto;color: #FFF;font-size: 25px;}.container #content {border: dashed 2px #CCC;padding: 10px;}#reset {padding: 5px 10px;background: #4CAF50;border: none;color: #FFF;cursor: pointer;}#reset:hover {color: #4CAF50;background: #FFF;}#viewContent table {width: 100%;}#viewContent table tr {height: 80px;background: darkcyan;}#viewContent table tr td {width: 50%;padding-left: 5px;}</style>
</head><body><div class="container"><div id="content"><h1>Implementing QRCoder in ASP.NET Core - Create QR Code File</h1><h2><a href="http://www.yogihosting.com/category/aspnet-core/">Read the tutorial on YogiHosting » </a><button id="reset" onclick="location=''">Reset »</button></h2><div id="viewContent">@using (Html.BeginForm(null, null, FormMethod.Post)) {<table><tbody><tr><td><label>Enter text for creating QR File</label></td><td><input type="text" name="qrText" /></td></tr><tr><td colspan="2"><button>Submit</button></td></tr></tbody></table>}</div>@{ if (Model != null) {<h3>QR Code file Successfully Generated</h3><img src="@String.Format(" data:image/png;base64,{0} ", Convert.ToBase64String(Model))" /> } }</div></div>
</body></html>
The code of this View is exactly similar to the ‘Index’ View and works exactly like it.
该视图的代码与“索引”视图完全相似,并且工作原理完全相同。
The URL to invoke this View is ‘http://localhost:50755/QRCoder/GenerateFile
’.
调用该视图的URL是' http://localhost:50755/QRCoder/GenerateFile
'。
读取并显示所有QR码文件(.qrr) (Read and display all the QR Code Files (.qrr))
You can also read all the .qrr files saved in the website. Go to your controller and add a new action called ‘ViewFile’:
您还可以阅读网站中保存的所有.qrr文件。 转到您的控制器并添加一个名为“ ViewFile”的新操作:
public IActionResult ViewFile()
{List<KeyValuePair<string, Byte[]>> fileData=new List<KeyValuePair<string, byte[]>>();KeyValuePair<string, Byte[]> data;string[] files = Directory.GetFiles("wwwroot/qrr");foreach (string file in files){QRCodeData qrCodeData = new QRCodeData(file, QRCodeData.Compression.Uncompressed);QRCode qrCode = new QRCode(qrCodeData);Bitmap qrCodeImage = qrCode.GetGraphic(20);Byte[] byteData = BitmapToBytes(qrCodeImage);data = new KeyValuePair<string, Byte[]>(Path.GetFileName(file), byteData);fileData.Add(data);}return View(fileData);
}
In this action method, I read the filed located in the ‘qrr’ folder using the code:
在此操作方法中,我使用以下代码读取了位于“ qrr”文件夹中的文件:
Directory.GetFiles("wwwroot/qrr")
Then I add each qrr file’s bytes and name inside a List<KeyValuePair<string, Byte[]>>
object.
然后,我在List<KeyValuePair<string, Byte[]>>
对象中添加每个qrr文件的字节和名称。
This object is returned to the View at the end:
该对象最后返回到视图:
return View(fileData);
Finally create the ‘ViewFile
’ View inside the ‘Views/QRCoder
’ folder with the following code:
最后,使用以下代码在“ Views/QRCoder
”文件夹中创建“ ViewFile
”视图:
@model List
<KeyValuePair<string, Byte[]>>
@{Layout = null;
}<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width" /><title>Implementing QRCoder in ASP.NET Core - View QR Code Files</title><style>body {background: #111 no-repeat;background-image: -webkit-gradient(radial, 50% 0, 150, 50% 0, 300, from(#444), to(#111));}h1,h2,h3 {text-align: center;color: #FFF;margin: 5px 0;}h1 {font-size: 30px;}h2 a {font-size: 25px;color: #0184e3;text-decoration: none;}h3 {font-size: 23px;border-bottom: solid 3px #CCC;padding-bottom: 10px;}h3 a {color: #00e8ff;text-decoration: none;}h3 a:hover,h2 a:hover {text-decoration: underline;}.container {width: 800px;margin: auto;color: #FFF;font-size: 25px;}.container #content {border: dashed 2px #CCC;padding: 10px;}#reset {padding: 5px 10px;background: #4CAF50;border: none;color: #FFF;cursor: pointer;}#reset:hover {color: #4CAF50;background: #FFF;}#viewContent table {width: 100%;}#viewContent table tr {height: 80px;background: darkcyan;}#viewContent table tr td {width: 50%;padding-left: 5px;}#viewContent table tr td img {width: 150px;}#viewContent table tr td span {display: block;}</style></head><body><div class="container"><div id="content"><h1>Implementing QRCoder in ASP.NET Core - View QR Code Files</h1><h2><a href="http://www.yogihosting.com/category/aspnet-core/">Read the tutorial on YogiHosting » </a><button id="reset" onclick="location=''">Reset »</button></h2><div id="viewContent"><table><tbody>@foreach (KeyValuePair<string, Byte[]> k in Model) {<tr><td><img src="@String.Format(" data:image/png;base64,{0} ", Convert.ToBase64String(k.Value))" /><span>@k.Key</span></td></tr>}</tbody></table></div></div></div></body></html>
This View displays all the qrr files as bitmap images inside a ‘HTML’ table. The below code creates the HTML table:
该视图将所有qrr文件显示为“ HTML”表中的位图图像。 下面的代码创建HTML表:
<table><tbody>@foreach (KeyValuePair<string, Byte[]> k in Model){<tr><td><img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(k.Value))" /><span>@k.Key</span></td></tr>}</tbody>
</table>
测试代码 (Testing the Code)
Run your application and go to the URL — ‘http://localhost:50755/QRCoder/ViewFile
’ to invoke the ViewFile Action method. You will see all the .qrr files saved in your website.
运行您的应用程序,然后转到URL —“ http://localhost:50755/QRCoder/ViewFile
”以调用ViewFile Action方法。 您将看到所有.qrr文件保存在您的网站中。
See the below image which illustrates it working:
请参见下图,它说明了它的工作原理:
You can download the full code from my GitHub Respositiory.
您可以从我的GitHub Repositiory下载完整的代码 。
结论 (Conclusion)
I hope you love this repository which will help you to use QRCoder in your ASP.NET Core Project. Make sure you like this repository to show your love to it.
我希望您喜欢这个存储库,它将帮助您在ASP.NET Core项目中使用QRCoder。 确保您喜欢此存储库以表示对它的爱。
If you need any help in ASP.NET Core then let me know in the below comments section.
如果您在ASP.NET Core中需要任何帮助,请在下面的评论部分中告诉我。
I publish 2 web development articles per week. Consider following me and get email notification whenever I publish a new tutorial on Medium. If this post was helpful, please click the clap button for a few times to show your support! It will bring a smile on my face and motivate me to write more for the readers like you.
我每周发表2篇Web开发文章。 每当我在Medium上发布新教程时,请考虑关注我并获得电子邮件通知。 如果此帖子有帮助,请单击拍手按钮几次以表示支持! 它会带给我微笑,并激励我为像您这样的读者写更多的文章。
I have also published another tutorial on freeCodeCamp, if you would like to see it too — How to create a login feature with Bootstrap Modal and jQuery AJAX
如果您也想在FreeCodeCamp上阅读,我也已发布了另一篇教程— 如何使用Bootstrap Modal和jQuery AJAX创建登录功能
Thanks and Happy Coding!
谢谢,祝您编码愉快!
翻译自: https://www.freecodecamp.org/news/how-to-easily-implement-qrcoder-in-asp-net-core-using-c-10c4aa857e84/
相关文章:

简述软件配置管理
http://blog.csdn.net/zhangmike/article/details/470477本文用菊子曰发布转载于:https://www.cnblogs.com/sdsunjing/p/5019791.html

startActivityForResult和setResult详解
startActivityForResult和setResult详解 原文:startActivityForResult和setResult详解startActivityForResult与startActivity的不同之处在于:1、startActivity( ) 仅仅是跳转到目标页面,若是想跳回当前页面,则必须再使用一次startActivity( …

小程序瀑布流实现
实现思路:把图片分成两排,创建两个数组,计算总数组中图片的宽高,对比上一个图片和当前的图片高度,低的就给另一个数组添加。效果图: 上代码: // miniprogram/pages/find/index.js const app g…

Webhooks上的一个简单方法:恐吓现在停止
Webhook.Webhook。 It sounds like what happens when you cross a spider and a pirate. In the world of the internet though, webhooks are something completely different. Webhooks help connect services together.听起来就像当您越过蜘蛛和海盗时会发生什么。 但是&a…

12.MySql关于获取当前时间的三个函数
这三个函数都是获取当前时间的,获取的详细格式如下图所示,可以根据需要来选用。 转载于:https://www.cnblogs.com/Nick-Hu/p/7566805.html

微信小程序云开发,使用阿里云短信服务,搜索员工生日定期发送短信。
相关API文档地址: 阿里云短信服务API文档地址 小程序云开发云函数正则匹配API文档地址 小程序云开发云函数定时触发器 1.登录阿里云,购买短信服务并添加签名和模板 2., 登录阿里云,鼠标放在右上角的头像图标就会显示 AccessKey…

信息安全系统设计基础家庭作业
《深入理解计算机系统》家庭作业 * 8.9 答案: 进程对 是否并发 AB 否 AC 是 AD 是 BC 是 BD 是 CD 是 * 8.10 答案: A. 调用一次,返回两次: fork B. 调用一次,从不返回: execve, longjmp C. 调…

css游戏代码_介绍CSSBattle-第一个CSS代码搜寻游戏
css游戏代码by kushagra gour由kushagra gour 介绍CSSBattle-第一个CSS代码搜寻游戏 (Introducing CSSBattle — the first CSS code-golfing game) If you are learning Web development or are already a professional Web developer, there is a very high chance you have…

IOS手机全屏长按识别二维码HTML代码
代码段作用讲解: 1. 二维码的全屏样式, opacity: 0; 透明样式, touch-callout: none; -webkit-touch-callout: none; -ms-touch-callout: none; -moz-touch-callout: none; 禁止IOS默认长按事件 .codePage {position: absolute;touch-callout: none;…

[亲测]在Mac下配置php开发环境:Apache+php+MySql
公司给我们配上了高大上的Apple Mac Pro本本,这两天自己正在习惯中。通过虚拟机PD,确实解决了一些因为工作习惯无法在iOS上很好完成的事情,但是我想,既然用起了iOS就尽量将一些事务在iOS环境下处理,免得好似关羽耍着大…

RabbitMQ 异常与任务分发
RabbitMQ 异常与任务分发 异常情况处理 上篇最后提到了这个问题, consumer异常退出、queue出错、甚至rabbitMQ崩溃。因为它们都是软件 ,软件都会有bug,这是无法避免的。所以RabbitMQ在设计的时候也想到了这一点 在之前,消息分发给…

reddit_如何使用Python创建自定义Reddit通知系统
redditby Kelsey Wang王凯西 如何使用Python创建自定义Reddit通知系统 (How to make a custom Reddit notification system with Python) Don’t you just love automated emails? I know I do. I mean, who doesn’t enjoy waking up to 236 new messages from Nike, Ticket…

1016. Phone Bills (25)
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yue去掉非法数据计算账单A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the…

样式集(五)微信朋友圈样式模拟
效果图: 小图标: 源码: <!--pages/findList/findList.wxml--> <image class"xxiangji" catchtap"xxiangji" src"/images/xxiangji.png"></image> <image class"top_img" src&…

为什么要选择useState而不是useReducer
by Austin Malerba奥斯汀马勒巴(Austin Malerba) 为什么要选择useState而不是useReducer (Why you should choose useState instead of useReducer) 通过useState进行本地和全局状态管理的指南 (A guide to local and global state management via useState) Since the introd…

php 类中的变量的定义
php 如果在类中定义变量,在类的方法中调用时应该加上$this-> . class ClassName {private $a 333;function __construct(){$this->a 2222;}public function bbb($value){echo $this->a;} } $b new className(); echo $b->bbb();转载于:https://www.c…

微信小程序云数据库触底分页加载,下拉无限加载,第一次请求数据随机,随机获取数据库的数据
效果图 小程序云开发分页加载代码 <!--pages/chatList/chatList.wxml--> <view class"pageTitle">家博慧</view> <view class" search_arr"><icon class"searchcion" size16 typesearch></icon><input …

Linux(Centos)之安装Java JDK及注意事项
1.准备工作 a.因为Java JDK区分32位和64位系统,所以在安装之前必须先要判断以下我们的Centos系统为多少位系统,命令如下: uname -a解释:如果有x86_64就是64位的,没有就是32位的。后面是X686或X86_64则内核是64位的&…

2019web前端趋势_2019年最值得关注的Web开发趋势
2019web前端趋势by Mrudul Shah通过Mrudul Shah 2019年最值得关注的Web开发趋势 (Top Web Development trends to look out for in 2019) Do you know that nearly 200 websites are pushed out every minute? Sounds astonishing right? But it is a fact and that’s why …

WPF入门教程系列九——布局之DockPanel与ViewBox(四)
七. DockPanel DockPanel定义一个区域,在此区域中,您可以使子元素通过描点的形式排列,这些对象位于 Children 属性中。停靠面板其实就是在WinForm类似于Dock属性的元 素。DockPanel会对每个子元素进行排序,并停靠在面板的一侧&…

tabBar 自定义,小程序自定义底部导航栏
创建一个自定义组件 my_tab,组件代码在后面,先看调用自定义组件的代码,比如我需要在index 页面调用,就在index.json中引用组件,index.json 代码(引用的路径为你创建的自定义组件路径) {"n…

2015年最新出炉的JavaScript开发框架
前端框架简化了开发过程中,像 Bootstrap 和 Foundation 就是前端框架的佼佼者。在这篇文章了,我们编制了一组新鲜的,实用的,可以帮助您建立高质量的 Web 应用程序的 JavaScript 框架清单。 1.Aurelia Aurelia是下一代JavaScript客…

小程序前端性能测试_如何提高前端应用程序的性能
小程序前端性能测试If your website takes longer than 3 seconds to load, you could already be losing nearly half of your visitors.如果您的网站加载时间超过3秒,则可能已经失去了将近一半的访问者。 Yes this is a fact, proven by several research studie…

10-TypeScript中的接口
接口是一种规约的约定,从接口继承的类必须实现接口的约定。在高级开发中,通常接口是用于实现各种设计模式的基础,没有接口,设计模式无从谈起。 定义接口: interface ILog{recordlog():boolean; } 类从接口继承…

样式集(六)仿微信通讯录样式
效果图: 这里有引用到 自定义底部导航,自定义底部导航组件链接 <!--pages/chatList/chatList.wxml--><!-- <include src"/components/common/common" /> --> <view class"top"><view class"pageTi…

WCF动态添加ServiceKnownType
WCF中传输自定义类型时,必须在服务接口类(服务协定)上加上ServiceKnownType(typeof(yourClass)), 在实际应用中比较麻烦,可以用动态的办法来实现动态添加。 服务接口类,加上一行 [ServiceKnownType("GetKnownType…

博客 rss 如何使用_如何使用RSS从您的GatsbyJS博客自动交叉发布
博客 rss 如何使用With the recent exodus from Medium many developers are now creating their own GatsbyJS Blogs and then cross-posting to Medium or publications like freecodecamp.org and dev.to.随着Medium最近的离职,许多开发人员现在正在创建自己的Ga…

大型技术网站的技术( 高并发、大数据、高可用、分布式....)(一)
面对高并发、大流量、高可用、海量数据、用户分布广泛、网络情况复杂这类网站系统我们如何应对??? 第一阶段 一台服务器不行就上多台服务器 1.应用程序与数据服务分离 将应用程序、数据库、文件等资源放在一台服务器上,面对海量…

BestCoder Round #65 B C D || HDU 5591 5592 5593
B 题意:ZYB在远足中,和同学们玩了一个“数字炸弹”游戏:由主持人心里想一个在[1,N][1,N]中的数字XX,然后玩家们轮流猜一个数字,如果一个玩家恰好猜中XX则算负,否则主持人将告诉全场的人当前的数和XX比是偏大还是偏小&a…

数组去重,ES6数组去重 new Set()
普通数组去重 var b [...new Set([1,2, 3, 4, 5, 5, 5, 5])]console.log(b); 输出结果: 包含对象的数组去重 var o {a:1}var b [...new Set([o, o, 3, 4, 5, 5, 5, 5])]console.log(b); 输出结果: 包含对象的数组去重有一个坑 var b [...new Set([{…