栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Javascript变量替换(CK编辑器)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Javascript变量替换(CK编辑器)

正如op所说,他们正在从数据库中获取模板。我认为这是一个字符串。您可以使用它来创建模板文字。

const template = "<p>This is the <strong>default </strong>CKEditor installation.${name} Source editing is provided by the Source Editing Area</a>&nbsp;plugin.</p><p>Follow the${city}steps below to try it${country}out:</p><ul><li>Click the <strong>Source </strong>button to display the HTML source of this tex ${website} ${email}in the source editing area.</li><li>Click the <strong>Source </strong>button again to return to the WYSIWYG view.</li></ul><form>First name:<br>"const replacements  = [{    "name": "Lijo",    "city": "Banglaore",    "country": "India",    "website": "",    "email": ""  },  {    "name": "Thoams",    "city": "Chennai",    "country": "India",    "website": "",    "email": ""  }]const inset = new Function('name', 'city', 'country', 'website', 'email', 'return `' + template + '`')const filledIn = replacements .map(({ name, city, country, website, email }) => inset(name, city, country, website, email) )console.log(filledIn)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418043.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号