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

做企业网站制作北京朝阳区最新通知

做企业网站制作,北京朝阳区最新通知,wordpress single_post_title,销售外包团队H5原生组件web Component Web Component 是一种用于构建可复用用户界面组件的技术#xff0c;开发者可以创建自定义的 HTML 标签#xff0c;并将其封装为包含逻辑和样式的独立组件#xff0c;从而在任何 Web 应用中重复使用。 !DOCTYPE html htmlhead…H5原生组件web Component Web Component 是一种用于构建可复用用户界面组件的技术开发者可以创建自定义的 HTML 标签并将其封装为包含逻辑和样式的独立组件从而在任何 Web 应用中重复使用。 !DOCTYPE html htmlheadmeta charsetutf-8 /meta nameviewport contentwidthdevice-width, initial-scale1 /titleweb Component原生组件/title/headbodym-button typeprimarywebComponent/m-buttontemplate idm-btnbutton classm-buttonslotDefault/slot/button/templatetemplate idm-btnstyle typetext/css.m-button {width: 100%;border: 1px solid #ebebeb;}/stylediv classm-collapseslot/slot/div/templatescript typetext/javascriptclass MButton extends HTMLElement {constructor() {super()let btnTmpl document.getElementById(m-btn) // 定义模板并获取模板let shadow this.attachShadow({ mode: open }) // 配置 devtools 是否可查看 DOM 结构open / closelet cBtnTmpl btnTmpl.content.cloneNode(true) // copy 模板便于重用cBtnTmpl.querySelector(.m-button).addEventListener(click, this.onClick)shadow.appendChild(cBtnTmpl) // 模板挂载 Shadow DOM}static get observedAttributes() {return [type] // 监控 type 属性是否改变}connectedCallback() {// 组件首次挂载时调用}attributeChangedCallback(key, oldValue, newValue) {// 组件更新时调用key 为属性名oldValue, newValue 为属性值}disconnectedCallback() {// 组件移除时调用}}/script/body /html Shadow DOM Shadow DOM 是 DOM nodes 的附属树。这种 Shadow DOM 子树可以与某宿主元素相关联但并不作为该元素的普通子节点而是会形成其自有的作用域Shadow DOM 中的根及其子节点也不可见。 不使用Shadow DOM !DOCTYPE htmlhtml langenheadmeta charsetUTF-8 /meta nameviewport contentwidthdevice-width, initial-scale1.0 /titleWeb Components/titlestyleh1 {font-size: 20px;color: yellow;} /style/headbodydiv/divhello-world/hello-worldh1Hello World! 外部/h1script typemoduleclass HelloWorld extends HTMLElement {constructor() {super();// 关闭 shadow DOM// this.attachShadow({ mode: open });const d document.createElement(div);const s document.createElement(style);s.innerHTML h1 {display: block;padding: 10px;background-color: #eee;}d.innerHTML h1Hello World! 自定义组件内部/h1;this.appendChild(s);this.appendChild(d);}tag hello-worldsay(something) {console.log(hello world, I want to say ${this.tag} ${something})}}window.customElements.define(hello-world, HelloWorld);const hw document.querySelector(hello-world); hw.say(good);/script/body/html使用 Shadow DOM !DOCTYPE html html langen head meta charsetUTF-8 / meta nameviewport contentwidthdevice-width, initial-scale1.0 / titleWeb Components/title styleh1 {font-size: 20px;color: yellow; } /style /head bodydiv/divhello-world/hello-worldh1Hello World! 外部/h1script typemodule class HelloWorld extends HTMLElement {constructor() {super();this.attachShadow({ mode: open });this.shadowRoot.innerHTML styleh1 {font-size: 30px;display: block;padding: 10px;background-color: #eee;}/styleh1Hello World! 自定义组件内部/h1;}tag hello-worldsay(something) {console.log(hello world, I want to say ${this.tag} ${something})}}window.customElements.define(hello-world, HelloWorld);const hw document.querySelector(hello-world); hw.say(good); /script /body /htmlHTML templates 和 slot 元素允许开发者在 HTML 中定义一个模板其中可以包含任意的 HTML 结构、文本和变量占位符。此元素及其内容不会在 DOM 中呈现但仍可使用 JavaScript 去引用它。 微前端 回顾微前端的历史最早的时候我们是利用 iframe 嵌入一个网页这就是微前端的雏形。虽然接入时方便快捷但它也存在一系列缺点如 路由状态丢失刷新一下iframe 的 url 状态就丢失了dom 割裂严重弹窗只能在 iframe 内部展示无法覆盖全局通信非常困难只能通过 postmessage 传递序列化的消息白屏时间太长对于有性能要求的应用来说无法接受 微前端的特点 路由隔离、js隔离、css隔离、预加载机制、通信机制、多微应用激活 import microApp from micro-zoe/micro-app; microApp.start();export function MyPage () {return (div h1子应用/h1 micro-app nameapp1 // name(必传)应用名称 urlhttp://localhost:3000/ // url(必传)应用地址会被自动补全为http://localhost:3000/index.html baseroute/my-page // baseroute(可选)基座应用分配给子应用的基础路由就是上面的 /my-page/micro-app /div )} js隔离沙箱 export class SnapShot { proxy: Window typeof globalThis constructor () { this.proxy window } // 沙箱激活 active () { // 创建一个沙箱快照 this.snapshot new Map() // 遍历全局环境 for (const key in window) { this.snapshot[key] window[key] } } // 沙箱销毁 inactive () { for (const key in window) { if (window[key] ! this.snapshot[key]) { // 还原操作 window[key] this.snapshot[key] } } }} microApp 使用过程中碰到的问题 webpack-dev-server中添加headers解决父应用引入子应用不同域名跨域问题 headers: {Access-Control-Allow-Origin: *,}原理解析 当调用 microApp.start() 后会注册一个名为 micro-app 的自定义 webComponent 标签。我们可以从 中拿到子应用的线上入口地址
http://www.hkea.cn/news/14278249/

相关文章:

  • 网站建设公司杭州企业网站建设外包
  • 南昌建网站那家好精准客户怎么营销
  • 使用iframe做网站wordpress使用菜单
  • 口碑好网站建设公司哪家好wordpress 集成paypal
  • 网站正在建设中 免费中企动力邮箱登陆
  • 制作人在那个网站能看广东融都建设有限公司 公司网站
  • 网站建设播放vr视频高校网站群建设
  • 点个赞科技 网站制作网页设计作品及代码
  • 中国建设银行北京分行门户网站公告wordpress 流程图插件
  • 泉州市第一建设有限公司网站南宁网站建设云尚网络
  • 网站建设公司年终总结西安专业做网站的公司哪家好
  • 网站模板在线制作泉州科技云网站建设
  • 网站公示如何做链接中太建设集团官方网站
  • 二道网站建设制作网站的图片素材
  • 用手机做电影网站瑞幸咖啡网络营销策划方案
  • ps网页制作视频教程宁晋seo网站优化排名
  • 用自己的服务器做网站网站建站代理
  • 网站建设怎么说服客户营销型网站建设课程培训现场
  • 北京市建设工程信息网站认证网站源码
  • 网站怎样添加友情链接怎么搭建个人网站
  • 无锡网站制作楚天软件如何在外国网站卖东西
  • 电子科技大学网站开发制定合同长春财经学院是一本还是二本
  • 广州网站营销优化qq做logo去哪个网站
  • 网站推广模板网站的目录怎样做的
  • 建立企业网站惠州做网站的公司有哪些
  • 德州专业网站制作哪家好lda模型 文本建模 wordpress
  • 旅行社的网站建设网站建设就业怎么样
  • 沈阳手机网站wordpress天气
  • 性价比高的网站建设做3d动画视频接私活的网站
  • 杭州建设网 工程信息网站wordpress主题--ux