window.open()跳转页面时需要传值情况(mvc例)

html代码

1 <script>
 2     function open_win() {
 3         window.open("@Url.Content("~/GoodsKind/CreateKinds")?oneKind=@ViewBag.OneKind", '', "height = 300, width = 400,resizable=0,top=350,left=600,location=no");
 4     }
 5 </script>
 6 
 7 <div>
 8     <button type="button" class="layui-btn" onclick="open_win()">
 9         <i class="layui-icon">&#xe608;</i> 添加
10     </button>
11 </div>

控制器代码

1 [HttpGet]
2         public ActionResult CreateKinds(int oneKind)
3         {
4             //实现代码
5         //....
6         //....
7         }

特别注意后缀的一致性(控制器需要参数名与window.open路径后缀参数名一致)(如上标红处)

 

posted @ 2021-02-18 01:40  飞渝  阅读(191)  评论(0)    收藏  举报