当前位置: 首页 > news >正文

网站建设专利申请成都品牌logo设计公司

网站建设专利申请,成都品牌logo设计公司,网站优化难吗,批量制作图片的软件官方网站: Web Component - Web API 接口参考 | MDN 1. 给一个html文件的路径字符串path, 存储对应path下的template,script,style数据 1) 传入path 2) 使用fetch将path字符串所在的文件找到并返回内容 const res await fetch(path).then(res res.text()); 3) 使用…官方网站: Web Component - Web API 接口参考 | MDN 1. 给一个html文件的路径字符串path, 存储对应path下的template,script,style数据 1) 传入path 2) 使用fetch将path字符串所在的文件找到并返回内容 const res await fetch(path).then(res res.text()); 3) 使用DOMParser实例的parseFromString方法将至转换为shadowRoot const parser new DOMParser(); const doc parser.parseFromString(res, text/html); // shadowRoot 4) shadowRoot支持dom查找元素的方法, 可以找到template, script, style标签元素 5) 根据不同的path, 存放相应的template, script, style // 动态加载组件并解析 async function loadComponent(path, name) {this.caches this.caches || {};// 当缓存存在if (!!this.caches[path]) {return this.caches[path]}const res await fetch(path).then(res res.text());// 利用DOMParser,生成shaow-rootconst parser new DOMParser();const doc parser.parseFromString(res, text/html);// 解析模板脚本样式const template doc.querySelector(template);const script doc.querySelector(script);const style doc.querySelector(style);// 缓存内容this.caches[path] {template,script,style}return this.caches[path] } 2. custom-component.js(自定义标签custom-component) // 容器组件 class CustomComponent extends HTMLElement {async connectedCallback() {console.log(custom-component connected);// 获取组件的path即html的路径const strPath this.getAttribute(path);// 加载htmlconst cInfos await loadComponent(strPath);// Element.attachShadow() 方法给指定的元素挂载一个 Shadow DOM并且返回对 ShadowRoot 的引用。const shadow this.attachShadow({ mode: closed });// 添加html对应的标签和内容this._addElements(shadow, cInfos);}_addElements(shadow, info) {if (info.template) {shadow.appendChild(info.template.content.cloneNode(true));}if (info.script) {var fn new Function(${info.script.textContent});// 绑定脚本的this为当前的影子根节点, 防止全局污染fn.call(shadow);}if (info.style) {shadow.appendChild(info.style);}} } window.customElements.define(custom-component, CustomComponent); 使用自定义标签custom-component // 使用示例: renderComponent.call(thisArg, route) function renderComponent(route) {var el document.createElement(custom-component);el.setAttribute(path, /${route.component}.html);// append可以追加节点和字符串appendChild只能追加节点el.id _route_;this.append(el); } 1) 先新建goods.html templatediv商品详情-goos/divdiv classproduct-id下面商品是????/div /templatescriptalert(这是商品页!!!) /scriptstyle.product-id{color: red;} /style2) 在index.html使用 先引入custom-component.js 然后在index.html的script标签写: renderComponent.call(document.getElementById(box), {component: ./goods}) index.html文件代码 !DOCTYPE html html langenheadmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleindex/titlestyle/style /headbodydiv idbox/div /bodyscript src./custom-component.js/scriptscriptrenderComponent.call(document.getElementById(box), {component: ./goods})/script /html
http://www.hkea.cn/news/14290711/

相关文章:

  • 适合建设网站的国外服务器网站点击率高
  • 江西响应式网站建设大理网站设计
  • 怎样在建设部网站下载规范做php网站前端价格
  • 做网站 视频加载太慢wordpress主题 mnews1.9
  • 网站怎么制作视频教程江苏网站建设开发
  • 如何做阿里巴巴的网站网页版微信二维码失效
  • 公众号自己做电影网站广告联盟怎么加入
  • o2o网站建设渠道阳江招聘网价格
  • 一键建站系统源码北京网站制作网站
  • 网站要设置哪些栏目抖音小程序推广
  • 济南大型网站制作网站怎么做弹出表单
  • 网站备案的要求简历模板个人简历
  • 超低价网站维护网站托管禹城网站建设价格
  • 建设网站的初步需要中秋网页制作素材
  • 建设开源社区网站什么意思wordpress弹框登陆
  • 定制网站建设公司哪家好商业网点建设中心网站
  • 郑州网站顾问热狗网什么自己做网站吗
  • ui网上接单网站网页版传奇下载
  • 做网站违法嘛李宁网站建设计划书
  • 百度做网站的联系人大数据营销策略有哪些
  • 事务所网站制作方案作文网站哪个平台好
  • 手机网站微信分享代码辽宁省城乡和住房建设厅网站
  • 电商平台正在建设中网站页面提示北京的电商平台网站有哪些
  • 厦门找一家做网站的公司深圳市住房与建设局网站
  • 城乡住房建设厅网站首页挖矿网站开发
  • 中能建设集团电子商务网站网站session
  • 阿里巴巴与慧聪网网站建设对比给艺术家做网站的工作
  • 古风网站建设wordpress 黑色
  • show-useragent wordpress 不显示广州百度seo 网站推广
  • 做和别人类似的网站侵权吗wordpress多个页面主题