resin-notes
技术栈

微前端

本文讲述无界微前端框架

webComponent

基本原理

//index.js
window.onload=()=>{
    class Wujie extends HTMLElement{
        constructor(){
            super()
            //shadowdom 样式隔离
          let dom = this.attachShadow({mode:"open"})
          let template = document.querySelector("#wujie")
          dom.appendChild(template.content.cloneNode(true))
        }
        console.log(this.getAttr('url))//api/wujie

        private getAttr(attr:string){
            retunr this.getAttribute(attr)//接收参数方法
        }
        //生命周期
        connectedCallback(){
            //创建
        }
        disconnectedCallback(){
            //销毁
        }
        attributeChangedCallback(){
            //类似vue的watch
        }
    }
    //类似于Vue组件,原生js写的组件
    window.customElements.define('wu-jie',Wujie)
}
//index.html
<script src='./index.js'/>
<wu-jie age="18" url="api/wujie"></wu-jie>
//给组件传参
<template id="wujie">
    <div style="bg:red">
        我是红色
    </div>
</template>

    <div>
        我是默认颜色
    </div>

pnpm+monorepo

pnpm的软硬链接

  1. 硬链接 修改index.js会导致ying.js也跟着改变
  2. 软链接
  3. 软硬链接

monorepo架构

相关文档

https://juejin.cn/post/7212603829572911159#heading-12

相关视频

https://www.bilibili.com/video/BV1tg4y1x75Q/?spm_id_from=333.788.videopod.episodes&vd_source=125c8d25332f7e1f3b59cdf33cb6aa27

On this page