我对我的代码中的语法错误(我猜想)有疑问。在测试时,我突然收到一条消息,说我的行中缺少括号。这是它的样子。实际上,我试图从我的数据库中获取信息,然后通过socket.io将其附加到我的前端。该代码中的错误在第3行上。
socket.on('matchoverview', function(data){
var $item1 = $("<div class='grid-item'><div class='row justify-content-md-center'><div class='col col-lg-1'></div><div class='col-lg-10'><div class='row'><div class='col-sm-3'><h3 id='insertteam1'><button id="" type='button' class='btn btn-dark'>Dark</button>" + data.teamonename + "</h3></div><div class='col-sm-3'><h3 id='insertpic1'>" + '<img id="logo" src=' + data.onelogo + '></img>' + "</h3></div><div class='col-sm-2'><h3 id='insertodd1'>" + data.teamoneodd + "</h3></div><div class='col-sm-2'><h3 id='insertclock'>" + data.time + "</h3></div><div class='col-sm-3'><h3 id='insertodd2'>" + data.teamtwoodd + "</h3></div><div class='col-sm-3'><h3 id='insertpic2'>" + '<img id="logo" src=' + data.twologo + '></img>' + "</h3></div><div class='col-sm-2'><h3 id='inserteam2'>" + data.teamtwoname + "</h3></div><div class='col-sm-2'><h3 id='inserttwitch'>" + data.twitchlink + "</h3></div></div></div></div></div>").click(function() {
console.log('Jo!');
});
var $item2 = $("<div class='grid-item'><div class='row justify-content-md-center'><div class='col col-lg-1'></div><div class='col-lg-10'><div class='row'><div class='col-sm-3'><h3 id='insertteam1'><button id="" type='button' class='btn btn-dark'>Dark</button>" + data.teamonename + "</h3></div><div class='col-sm-3'><h3 id='insertpic1'>" + '<img id="logo" src=' + data.onelogo + '></img>' + "</h3></div><div class='col-sm-2'><h3 id='insertodd1'>" + data.teamoneodd + "</h3></div><div class='col-sm-2'><h3 id='insertclock'>" + data.time + "</h3></div><div class='col-sm-3'><h3 id='insertodd2'>" + data.teamtwoodd + "</h3></div><div class='col-sm-3'><h3 id='insertpic2'>" + '<img id="logo" src=' + data.twologo + '></img>' + "</h3></div><div class='col-sm-2'><h3 id='inserteam2'>" + data.teamtwoname + "</h3></div><div class='col-sm-2'><h3 id='inserttwitch'>" + data.twitchlink + "</h3></div></div></div></div></div>").click(function() {
console.log('Jo!');
});
$grid2.append( $item1 ).masonry( 'appended', $item1 );
$grid2.append( $item2 ).masonry( 'appended', $item2 );
});
错误代码:
Uncaught SyntaxError: missing ) after argument list
预先感谢,祝您愉快
答案 0 :(得分:0)
请确保您的字符串定界符已正确放置并放置。
在“”和“”上出现
<button id=""
到
<button id=''
和您的
src='+variable+'
必须为
src='" +variable+ "'
谢谢!