大家好,我的js错误是Eclipse没有向我显示它在行中的位置。你有什么想法吗?谢谢! 这是我的代码:
function createVersionRow(appKey, version, status) {
var value = (appKey + ';' + version);
return '<tr id="' + getVersionRowID(appKey, version) + '"><td>' + version + '</td><td class="text-center"><input type="radio" name="version"'+ onchange="changeVersionStatus(this);"'></td><td>' + status + '</td></tr>';
}
错误就是退货。
这里是功能getVersionRowID:
function getVersionRowID(appKey, version) {
return 'row-app-version-' + (appKey + '-' + version).replace(/\./g,'-');
}
这是函数changeVersionStatus:
function changeVersionStatus(obj) {
var info = $(obj).val().split(";");
loadVersion(info[0], info[1]);
}
可以在我调用changeVersionStatus时吗?
答案 0 :(得分:0)
构建字符串的方式中存在错误。您的报价不匹配
return '<tr id="' +
getVersionRowID(appKey, version) +
'"><td>' +
version +
'</td><td class="text-center"><input type="radio" name="version"'+
onchange="changeVersionStatus(this);"'></td><td>' <-- error is here
+ status + '</td></tr>';
您将其随机关闭,不确定为什么...
return '<tr id="' +
getVersionRowID(appKey, version) +
'"><td>' +
version +
'</td><td class="text-center"><input type="radio" name="version" onchange="changeVersionStatus(this);"></td><td>' +
status + '</td></tr>';
如果碰巧使用支持ES6的浏览器,最好使用模板文字。 (请注意,并非所有浏览器都支持以下功能)
var id = getVersionRowID(appKey, version)
return `<tr id="${id}">
<td>${version}</td>
<td class="text-center">
<input type="radio" name="version" onchange="changeVersionStatus(this);">
</td>
<td>${status}</td>
</tr>`