Sh.Knockout
1.0.1
dotnet add package Sh.Knockout --version 1.0.1
NuGet\Install-Package Sh.Knockout -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sh.Knockout" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sh.Knockout" Version="1.0.1" />
<PackageReference Include="Sh.Knockout" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sh.Knockout --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sh.Knockout, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sh.Knockout@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sh.Knockout&version=1.0.1
#tool nuget:?package=Sh.Knockout&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
KO 与jqurey validate 的验证集成
简单 记录一下 本来是想 设计一个 partview 但是发现集成起来没有多少代码 就直接写了文昌的 方比那自己 ,使用及,这里表单模型验证都应以在 Model 上了 这需要你有 asp.net web 开发经验就欧克了
页面要引用:
<form id="form" asp-page="" data-bind="event:{submit:function(){save($element)}}" method="post">
<input asp-for="Model.Name" />
<span asp-validation-for="Model.Name"></span>
<button type="submit">save</button>
</form>
<partial name="_ValidationScriptsPartial" />
<script src="~/lib/knockout/build/output/knockout-latest.js"></script>
<script>
var vm = {
save: function (t) {
$form = $(t);
// $.validator.unobtrusive.parse($form);这里用于一部加载试图时需要 设置这个初始化
// $form.validate(); // 手动调用验证
if ($form.valid()) {
$.post($form.attr("action"), $("form").serialize(), function (result) {
console.info(result);
})
}
}
}
ko.applyBindings(vm);
</script>
分页 的用法
客户端分页
使用的是 ko js 做的分页,分为两种使用方式 ,
都需要引用.ko ,及 kopage.js 接口返回的数据结构是 \
json:
{count:100 ,data:[]};
ViewModel 中包含 page 模型
这种方式使用 PageViewInside 在shared 文件夹中
@{
var pa = "page"; //此处的page 与 page: pa 配置为一样
}
<script src="/_content/Sh.Knockout/js/kopage.js"></script>
<partial name="PageViewInside" model="pa" />
<script>
function cal(data) {
console.info("sssssssssss", data);
//这里绑定你的 table
}
var pa = new kopage(cal, 'https://localhost:44346/Index/Ge', null, 5, 20, 2020);
var vm = {
page: pa
}
ko.applyBindings(vm);
</script>
ViewModel 中不包含 page 模型
这种方式使用 PageViewOutSide 在shared 文件夹中
<script src="/_content/Sh.Knockout/js/kopage.js"></script>
<partial name="PageViewOutSide" />
function cal(data) {
console.info("sssssssssss", data);
//这里绑定你的 table
}
var pa = new kopage(cal, 'https://localhost:44346/Index/Ge', null, 5, 20, 2020);
ko.applyBindings(pa, document.getElementById("kopage"));
服务端分页
使用方
// 页面模型 必须是 Sh.Knockout.PageViewModel<t>
@Html.Partial("PageView",Model.ToPageViewModel("onclick='reload({0})'"))
<script>
function reload(id) {
var searchdata = $("#searchform").serialize();
window.location.href = "/Letyoufly/ADlist?take=20&index=" + id + "&" + searchdata
}
</script>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Knockout.Validation (>= 2.0.4)
- knockoutjs (>= 3.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.