首页 > 解决方案 > 在功能 js 的屏幕上查看打印结果

问题描述

function findBrother(name) {
       fetch(urlBrother +name)
      .then((response) => {
        if (response.status === 200) {
          return response.json();
        } else throw new Error(response.status);
      })
      .then((data) => {
        const brotherName = data[0].name
        const flagCountry = data[0].flag
        if (data[0].brother.length > 0) {
          console.log(data[0].brother);
          console.log(data[0].flag);
          document.getElementById("_flag").innerHTML=flagCountry;

该函数位于文件 A.js 中,我想打印 flagCountry 的结果。我如何在 HTML 中做到这一点?这是来自网址的图像。

标签: htmlprinting

解决方案


推荐阅读