我有一個ASP.NET Razor視圖這樣的:如何調用JavaScript爲每個表格行畫一個畫布?
@{
this.Layout = null;
}
<script type="text/javascript">
function drawWindArrow(canvas, windDirection) {
// Draw something
}
</script>
<table style="width: 100%">
@foreach (var weather in ViewBag.WeatherForecastList)
{
double windDirection = weather.WindDirection;
<tr>
<td>
<canvas width="32" height="32"></canvas>
How can I call drawWindArrow with the canvas and the windDirection as a parameter???
</td>
</tr>
}
</table>
我想這是爲表中的每一行不同的畫布上畫點什麼。它應該類似於這裏找到箭頭:http://www.yr.no/sted/Norge/Oslo/Oslo/Oslo/,但我不希望使用靜態圖片,因爲我需要基於一些CSS3的款式不同的顏色來繪製。
我怎麼能說與畫布和windDirection作爲參數drawWindArrow JavaScript函數?
VAR可以= document.createElement(「canvas」); https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes – 2012-02-25 07:57:30
那麼,創建一個Canvas並繪製它很簡單。但是,對於每個具有不同參數的表格行,我該怎麼做呢? – Olav 2012-02-25 08:23:42