# ming_router **Repository Path**: minglie/ming_router ## Basic Information - **Project Name**: ming_router - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-26 - **Last Updated**: 2022-09-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ming_router ming_router 是一个路由与组件库,目的是在不使用构建工具的情况下开发开发单页应用 # cdn https://unpkg.com/ming_router/src/index.js # 访问路径 http://localhost:8888/index.html#/a http://localhost:8888/index.html#/b http://localhost:8888/index.html#/c # 模板解析规则 "#usercard" : 从dom解析 "./usercard.html": 从html文件 "
hello
": 从字符串 # 组件 自定义组件必须中划线分割,tag名从函数名或类名转换而来 类组件实例 MingRouter.componentMap.组件类名.组件key 函数组件无实例 只能用 dom.setAttibute(k,v) 触发组件更新 ## 组件demo01(组件定义) ```html Document




``` ## 组件demo02(类组件详情) 没有虚拟dom与diff算法,组件只是局部更改,则直接用js改即可 document.querySelector('user-card'). shadowRoot.querySelector('#myImgId'). setAttribute("src","aa") this.setState()会直接替换整个dom,效率不高 ```html Document
``` ## 路由demo ```html 路由demo

``` # 路由切换刷新 ```js //不可返回 MingRouter.replaceHash("/b") //可返回 location.hash="#/b"; //只改内容不改路由,类似后端转发,这个render不会执行路由mapping的回调 mingRouter.render([path]) ``` # ming_router语雀文档 https://www.yuque.com/docs/share/a87701d4-bb25-4d0a-b42d-225f834f9b7c # 参考demo https://gitee.com/minglie/ming_node_router