[英]How not works mix code JS in a Razor View
I try to use in a View a JS function and mix with a Razor Code, but for any reason after the code marked FROM HERE not continues the execution of function, something missing to the function to continue after included the Razor code?
<script type="text/javascript">
FusionCharts.ready(function () {
var data2 = [];
@for (var i = 0; i < totalt; i++)
{
@:data2.push({
@:label: "@data.Results[i].Timestamp",
@:value: "@data.Results[i].Value",
});
**FROM HERE**
var chartObj = new FusionCharts({
type: 'line',
renderAt: 'chart-containeriot',
width: '493',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"showBorder": "0",
"showShadow": "0",
"use3DLighting": "0",
"showLabels": "0",
"showValues": "1",
"paletteColors": "#58E2C2, #F7E53B",
"bgColor": "#191c51",
"bgAlpha": "100",
"canvasBgAlpha": "0",
"decimals": "0",
"baseFont": "Arial",
"baseFontColor": "#FFFFFF",
"canvasTopMargin": "0",
"showTickMarks": "0",
"showTickValues": "0",
"showLimits": "0",
"majorTMAlpha": "0",
"minorTMAlpha": "0",
"pivotFillAlpha": "0",
"showPivotBorder": "0",
"xAxisName": "Day",
"yAxisName": "Metros Cubicos",
"lineThickness": "2"
},
"data": data2
}
});
chartObj.render();
});
</script>
Razor 将@
解释为 razor 语法。 您应该使用@@
转义您的代码
@@:data2.push({
@@:label: "@data.Results[i].Timestamp",
@@:value: "@data.Results[i].Value",
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.