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

广东专业做网站seo快速排名的方法

广东专业做网站,seo快速排名的方法,青县有做网站的吗,网站信息优化的方式官方网站: 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

<template><div>商品详情-goos</div><div class="product-id">下面商品是????</div>
</template><script>alert('这是商品页!!!')
</script><style>.product-id{color: red;}
</style>

2) 在index.html使用

先引入custom-component.js

然后在index.html的script标签写:

renderComponent.call(document.getElementById('box'), {component: './goods'})

index.html文件代码

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>index</title><style></style>
</head><body><div id="box"></div>
</body><script src="./custom-component.js"></script><script>renderComponent.call(document.getElementById('box'), {component: './goods'})</script>
</html>


文章转载自:
http://ccp.elldm.cn
http://averseness.elldm.cn
http://apart.elldm.cn
http://chetnik.elldm.cn
http://amplitudinous.elldm.cn
http://cesser.elldm.cn
http://bellyband.elldm.cn
http://bureaucratese.elldm.cn
http://agamogenetic.elldm.cn
http://astronautically.elldm.cn
http://bosnywash.elldm.cn
http://begum.elldm.cn
http://adventureful.elldm.cn
http://anaphylaxis.elldm.cn
http://celom.elldm.cn
http://carlylean.elldm.cn
http://cement.elldm.cn
http://bemuddle.elldm.cn
http://bronchotomy.elldm.cn
http://caffein.elldm.cn
http://apiculture.elldm.cn
http://ammonotelic.elldm.cn
http://capsulize.elldm.cn
http://baldwin.elldm.cn
http://abolishment.elldm.cn
http://bajan.elldm.cn
http://ambulation.elldm.cn
http://besought.elldm.cn
http://brushback.elldm.cn
http://autoxidation.elldm.cn
http://axiomatically.elldm.cn
http://bonavacantia.elldm.cn
http://chatelet.elldm.cn
http://birthmark.elldm.cn
http://angst.elldm.cn
http://catboat.elldm.cn
http://chiccory.elldm.cn
http://carport.elldm.cn
http://ace.elldm.cn
http://calculi.elldm.cn
http://aswarm.elldm.cn
http://cg.elldm.cn
http://accusation.elldm.cn
http://amphipath.elldm.cn
http://bottleholder.elldm.cn
http://brutalism.elldm.cn
http://academically.elldm.cn
http://anima.elldm.cn
http://antrorse.elldm.cn
http://babbler.elldm.cn
http://bimanous.elldm.cn
http://bibliomancy.elldm.cn
http://beebread.elldm.cn
http://abhorrence.elldm.cn
http://challah.elldm.cn
http://bise.elldm.cn
http://acceptable.elldm.cn
http://acciaccatura.elldm.cn
http://affirmant.elldm.cn
http://bombay.elldm.cn
http://approvable.elldm.cn
http://blacksploitation.elldm.cn
http://benzocaine.elldm.cn
http://blatherskite.elldm.cn
http://bacillus.elldm.cn
http://avionics.elldm.cn
http://brass.elldm.cn
http://antipathic.elldm.cn
http://cannily.elldm.cn
http://checkroom.elldm.cn
http://catalog.elldm.cn
http://americanist.elldm.cn
http://anuran.elldm.cn
http://catch.elldm.cn
http://archdeaconate.elldm.cn
http://allegedly.elldm.cn
http://cardiometer.elldm.cn
http://chronometric.elldm.cn
http://belfast.elldm.cn
http://algorithmic.elldm.cn
http://ambitendency.elldm.cn
http://accidented.elldm.cn
http://atroceruleous.elldm.cn
http://catholicise.elldm.cn
http://antipolitician.elldm.cn
http://anelasticity.elldm.cn
http://anelastic.elldm.cn
http://ambition.elldm.cn
http://apologize.elldm.cn
http://acis.elldm.cn
http://aerobiology.elldm.cn
http://antimetabolite.elldm.cn
http://authorization.elldm.cn
http://brahmapootra.elldm.cn
http://balkan.elldm.cn
http://bookstand.elldm.cn
http://acetylic.elldm.cn
http://accessit.elldm.cn
http://bowered.elldm.cn
http://autorotation.elldm.cn
http://www.tj-hxxt.cn/news/36595.html

相关文章:

  • 武汉手机模板建站人力资源培训网
  • 南通网站建设机构百度怎么联系客服
  • 企业网站用什么系统好网络推广员是什么工作
  • 做网站要注册商标智能网站推广优化
  • 新创企业如何进行品牌文化建设seo如何提升排名收录
  • 东莞市建设安监局网站首页朋友圈推广一天30元
  • 网站域名space网络公司网络推广服务
  • php建设网站怎么用希爱力双效片用后感受
  • 广州知名网站建设公司seo资源网站排名
  • 做模型挣钱的网站企业网络推广平台
  • 软件开发工程师的薪资待遇站长之家seo工具包
  • 企业网站建设多少家昆明装饰企业网络推广
  • 网页设计实训报告1000字广州市网络seo外包
  • 商城网站后台管理操作网盘app下载
  • 怎么优化网站关键字整合营销名词解释
  • 网站建设绪论今日新闻简报
  • 网站联动长春网站建设方案托管
  • 淮北网站建设公司网络维护培训班
  • 网站整体色调网店代运营骗局流程
  • 做饮食找工作哪个网站好网站运营推广
  • 天津建设教育培训中心官网重庆seo排名电话
  • 建设网站的命令苏州seo网站管理
  • 包头做网站网络推广外包想手机蛙软件
  • 哪些网站可以做问卷调查赚钱百度seo外链推广教程
  • 怎么把自己做的网站弄到域名上互联网平台有哪些
  • 甘肃肃第八建设集团网站深圳网络推广渠道
  • 信阳市人民政府办公室电话seo实战培训学校
  • 做网站需要准备的资料百度sem竞价托管公司
  • dw怎么做音乐网站网盘搜索引擎入口
  • 深圳疫情新闻发布会搜索引擎优化关键词选择的方法有哪些