我正在任务板上。我想显示配方设计师的图像并显示它。 您可以检查我的代码(只是一个函数)以了解我想要做什么。
function createIssueTemplate({
id,
status,
description,
severity,
assignedTo,
/*<img src='${image}'></img>*/
image
}) {
return (
`<div class="well">
<h6>Issue ID: ${id} </h6>
<p><span class="label label-info">${status}</span></p>
<h3>${description}</h3>
<p><span class="glyphicon glyphicon-time"></span>${severity}
<span class="glyphicon glyphicon-user"></span>${assignedTo}</p>
<a href="#" class="btn btn-warning" onclick="setStatusClosed('${id}')">Close</a>
<a href="#" class="btn btn-danger" onclick="deleteIssue('${id}')">Delete</a> <br> <br>
</div>`
);
}
答案 0 :(得分:0)
问题是由于函数参数中的语法所致。您在其中放置了一个对象,而不是各个参数名称。如果您纠正了该错误,那么您的逻辑就可以正常工作:
function createIssueTemplate(id, status, description, severity, assignedTo, image) {
return `<div class="well">
<h6>Issue ID: ${id} </h6>
<p><span class="label label-info">${status}</span></p>
<h3>${description}</h3>
<p><span class="glyphicon glyphicon-time"></span>${severity}
<span class="glyphicon glyphicon-user"></span>${assignedTo}</p>
<a href="#" class="btn btn-warning" onclick="setStatusClosed('${id}')">Close</a>
<a href="#" class="btn btn-danger" onclick="deleteIssue('${id}')">Delete</a> <br> <br>
<img src='${image}'></img>
</div>`
}
$('#foo').append(createIssueTemplate('Id', 'Status', 'Description', 'Severity', 'AssignedTo', 'Image.jpg'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="foo"></div>