React `${}` 格式


//config.js
module.exports = {
  getAPIPath() {}
}

import globalConfig from "../config"; 
`${globalConfig.getAPIPath()}

`` 創建一個字符串 不需要使用字符串連接
// Current time string
const time = new Date().toLocaleTimeString();
// 使用普通字符串(單引號或雙引號)時,需要使用字符串連接:
'Time is ' + time
// 在使用反引號時,可以使用 ${} 在字符串中注入時間
`Time is ${time}`

  

serviceNameShow(type, content1) {
  const content = JSON.parse(content1);
  if (type === 0) {
    return content['platformInfo']['name'] + ':' + content['platformInfo']['version'];
  } else if (type === 1) {
    let character = ``;
    JSON.parse(content['serviceMsg']).map(item => {
      character += `<p>${item['serviceName']}:${item['serviceVersion']}</p>`;
    });
    return character;
  } else if (type === 2) {
    const character = `<p>${content['platformInfo']['name']}:${content['platformInfo']['version']}</p>
                      <p>${content['platformInfo']['old']} -> ${content['platformInfo']['version']}</p>`;
    return character;
  } else if (type === 3) {
    const character = `<p>${content['platformInfo']['name']}:${content['platformInfo']['version']}</p>
                      <p>${content['platformInfo']['old']} -> ${content['platformInfo']['replicas']}</p>`;
    return character;
  } else if (type === 4) {
    return content['platformInfo']['name'] + ':' + content['platformInfo']['version'];
  }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM