追加..mobile结束视图名称的行为不正常 [英] Appending ..mobile to end of view name behaving erratically

查看:128
本文介绍了追加..mobile结束视图名称的行为不正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个视图,仅适用于移动网站的负载。 显然中添加。移动到视图名称所以_Layout.cshtml变得_Layout.Mobile.cshtml会导致如果设备上的移动浏览视图被加载。我有这个工作在首先查看我的VS项目使用 - _Layout.cshtml,但随后在加载 @ Html.Partial(MVC.Shared.Views._Header,型号),该文件,我本来期望同样的事情有这种情况发生,它会知道载入_Header.Mobile.cshtml视图,而不是,但事实并非如此。这是否意味着我必须手动更改视图的所有引用都在。移动他们的意见结束了吗?我以为。移动的一点是,它自动地知道使用这个?

I am trying to create a view that loads only for mobile sites. Apparently, adding .mobile to a view name so _Layout.cshtml becomes _Layout.Mobile.cshtml causes that view to be loaded if the device is viewed on a mobile. I have got this working for the very first view my VS project uses - _Layout.cshtml, but then in that file it loads @Html.Partial(MVC.Shared.Views._Header, Model), I would have expected the same thing to happen with this, that it would know to load the _Header.Mobile.cshtml view instead, but it doesn't. Does this mean I have to manually change all the references to views to have .Mobile at the end of them in the views? I thought the point of the .Mobile was that it knew automatically to use this?

推荐答案

我要说的是,你必须通过名字来加载部分为它工作,您指定一个特定的文件存在。

I would say that you would have to load the partial by name for it to work, you are specifying a particular file there.

您可以使用加载它

@Html.Partial("_Header", Model)

这篇关于追加..mobile结束视图名称的行为不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆