【发布时间】:2017-01-08 22:56:54
【问题描述】:
js代码
if ($language == 'english') {
var displayvalue = "";
if (data[i].report_name.length >= 20) {
displayvalue = data[i].report_name.substr(0, 20) + "...";
} else {
displayvalue = data[i].report_name
}
subMDesign += '<a href="" ng-click="getIndividualGraph(' + data[i].report_id + ',' + data[i].report_type + ')" ondragstart="event.dataTransfer.setData(text, drag.action?reportId=' + data[i].report_id + '&reportType=' + data[i].report_type + '_' + data[i].report_id + '_' + data[i].report_type + '_22)"><span class="iconsweet">r</span><span class="tooltips" title="' + data[i].report_description + '" unselectable="on">' + displayvalue + '</span></a>';
} else {
var displayvalue = "";
if (data[i].report_name.length >= 20) {
displayvalue = data[i].report_name_ar.substr(0, 20) + "...";
} else {
displayvalue = data[i].report_name_ar;
}
subMDesign += '<a href="" ng-click="getIndividualGraph(' + data[i].report_id + ',' + data[i].report_type + ')" ondragstart="event.dataTransfer.setData(text, drag.action?reportId=' + data[i].report_id + '&reportType=' + data[i].report_type + '_' + data[i].report_id + '_' + data[i].report_type + '_22)"><span class="iconsweet">r</span><span class="tooltips" title="' + data[i].report_description + '" unselectable="on">' + displayvalue + '</span></a>';
}
}
var temp = $compile(subMDesign)($scope);
$("#reportUl" + $catid).html(temp);
我将subMDesign 动态附加到最后一行的div。在控制台中,subMDesign显示如下:
拖动开始时,控制台显示错误如下:
ReferenceError:左侧赋值无效 event.dataTransfer.setData(text, drag.action?reportId=93&reportType=6_93_6_22)
并且箭头标记指向reportId=93。请帮我解决这个问题。
【问题讨论】:
-
什么?您知道确切的位置,并且错误消息很清楚。您需要什么样的帮助?
-
但我不知道那个位置有什么问题
-
drag.action?reportId=93&reportType=6_93_6_22在纯 JS 中做什么?它看起来像是 URL 的一部分,但在您的代码中它实际上是一个赋值。 -
为reportId和reportType赋值并转到drag.action
-
进入地址栏时,是的,但不是在 JS 中。 JavaScript 没有 url 数据类型。
标签: javascript jquery css angularjs