Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MVC3中,我在将模型变量输出到JavaScript中时收到“关闭条件编译”警告_Javascript_Visual Studio 2010_Razor_Compiler Warnings - Fatal编程技术网

在MVC3中,我在将模型变量输出到JavaScript中时收到“关闭条件编译”警告

在MVC3中,我在将模型变量输出到JavaScript中时收到“关闭条件编译”警告,javascript,visual-studio-2010,razor,compiler-warnings,Javascript,Visual Studio 2010,Razor,Compiler Warnings,我正在使用ASP.NETMVC3和Razor。以下是导致警告的代码: var userLocation = new google.maps.LatLng(@Model.Latitude, @Model.Longitude); 代码在运行时运行良好,但我想了解警告 编辑 以下是更多相关代码: function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); v

我正在使用ASP.NETMVC3和Razor。以下是导致警告的代码:

var userLocation = new google.maps.LatLng(@Model.Latitude, @Model.Longitude);
代码在运行时运行良好,但我想了解警告

编辑

以下是更多相关代码:

    function initialize() {
        directionsDisplay = new google.maps.DirectionsRenderer();
        var userLocation = new google.maps.LatLng(@Model.Latitude, @Model.Longitude);
        var myOptions = {
            zoom: 15,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: userLocation
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        directionsDisplay.setMap(map);
    }
如果我这样添加括号:

var userLocation = new google.maps.LatLng(@(Model.Latitude), @(Model.Longitude));

我收到一个新的警告,无效字符。

问题不在您提供的行中,它只是基于您提供的代码之外的错误导致警告


一般来说,这是一个js错误,与Razor或VS无关,但通常是由于缺少括号或s引号引起的。你能分享一下周围的代码吗?

sry如果我不清楚,如果错误在这一行之外,那么这一行中没有括号缺失。您提供的扩展代码表明,在使用razor语法时,似乎会立即出现错误,这是一个明确的迹象,表明在html/js中存在错误之前,您可以提供完整的代码垃圾,包括脚本标记吗?