返回JavaScript中的html文件中的图像

所以我现在要在这个index.js中返回这个html文件,我想在返回的html中有一个图像路径,但是我无法链接到同一目录中的任何图像,对此是否有解决方案

module.exports = ({title, artist, period, domain,interest,material}) => {
    const today = new Date();
    var path = "../../client/src/logo.svg"
    return `
    <!doctype html>
    <html>
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    <div class="base-container">
        <div class="header">
            <a>Art Driven Innovation</a>
        </div>
        <divclass="midsection">
            <div class="leftside">
                <div class="artworkfirst">
                    <div class="artwork">
                        <div class="boxArtwork">artwork</div>
                    </div>
                </div>
                <div class="Artworksecond">
                    <div class="top-part">
                        <div class="box1">
                            <div class="text1"><div class="interestheading">Artistic interest</div><div class="artisticinterest+pic"><div class= "imageInterest"><img id = "InteresrtPic" class = "picInterest"></img></div><div id = "interestText" class= "interest">${interest}</div></div></div>

            </div>

    <script>
        var pop = "${interest}";
        if(pop.localeCompare("Explore new paths to progress")===0)
        {

            document.getElementById("InteresrtPic").src = "https://cdn.clipart.email/b7c4cc7357dd17e1ce58835bcbb43bbb_target-clipart-transparent_400-400.png";
        }
        if(pop.localeCompare("Questioning Technology")===0)
        {
            document.getElementById("InteresrtPic").src = "http://pngimg.com/uploads/question_mark/question_mark_PNG125.png";
        }
        if(pop.localeCompare("Taking science out of the lab")===0)
        {
            document.getElementById("InteresrtPic").src = "${path}";
        }
    </script>
    </body>
    </html>
   `;
};
评论