對不起,我的英語不太好,所以請儘量理解。爲什麼c#在剃鬚刀的js中解碼
下面是代碼:
@{
Layout = null;
var str = "http://example.com?a=1&b=2";
}
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Title</title>
</head>
<body>
<script>
$(function() {
console.log('@str');
});
</script>
</body>
</html>
我的期望是http://example.com?a=1&b=2
,但在控制檯,結果是http://example.com?a=1&b=2
。
請向我解釋,謝謝。
我沒有看到任何不同嗎? – Se0ng11
該字符串是否編碼?我沒有看到這些結果之間的任何區別。如果我的猜測正確,請使用'@ Html.Raw(str)'。 –
@panshu您的期望和問題中的當前輸出是一樣的!隨着您發佈的代碼,當前輸出將是'http://example.com?a=1 & b = 2' – Shyju