当我将此代码用作脚本时,我在控制台中收到此错误:
语法错误:缺少变量名
$(document).ready(function () {
var multiselect = $("#TahiyeKonande").data("kendoMultiSelect");
var arr = [];
var t = @ttt;
var tt = t.split(",");
console.log(tt);
// set the value of the multiselect.
console.log(arr);
multiselect.value(arr);
});
答案 0 :(得分:4)
要将razor viewbag字符串转换为js,请使用双引号
$(document).ready(function () {
var multiselect = $("#TahiyeKonande").data("kendoMultiSelect");
var arr = [];
var t = "@ttt";
var tt = t.split(",");
console.log(tt);
// set the value of the multiselect.
console.log(arr);
multiselect.value(arr);
});