我的視圖中有一個視圖組件
@await Component.InvokeAsync("UserProfileCard")
我希望當我點擊一個按鈕時,只有這個組件會重繪 ,而不會使用 jquery ajax 或 jquery Unobtrusive 重繪 頁面
uj5u.com熱心網友回復:
在組件周圍創建 div
<div id="userProfileCard">
@await Component.InvokeAsync("UserProfileCard")
</div>
創造行動
public class MyController : Controller {
public IActionResult GetUserProfileCardComponent() {
return ViewComponent("UserProfileCard", <arguments...>);
}
}
阿賈克斯
<script>
$.get("/MyController/GetUserProfileCardComponent", function(data) {
$("#userProfileCard").html(data);
});
</script>
uj5u.com熱心網友回復:
我所知道的使用 jQuery 的方式是重新繪制呈現頁面的 div/span 的 .html() 并使用組件的新內容重繪 它
eq:讓我們假設 userProfileCard 是一個 div,那么代碼就像 -:
$("#userProfileCard").html(newData)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/322259.html
上一篇:級聯引數Task<AthenticationState>如何在BlazorWASM中的AuthorizeView和AuthorizedRouteView中解包并公開為“背景關系”?
