Comments (4)
在目前现有的组件构建方案里面,可以考虑把 mip-vd-tabs 和 vd-tab 分别弄成两个组件 在 html 里引入即可达到你想要的效果
from mip2.
@clark-t 单独开发两个组件确实可以,有俩问题
- 两个是配套的组件,但是需要分别引入两个js文件,关联性太低,提测、管理、上线,都比较麻烦
- 如果一个组件需要拆分成三个五个,那这无疑增加了组件的数量,想想mip1,700+的站长组件……
from mip2.
这个问题的解决方案呢?节前其实已经有结论了, @clark-t 这个可以写一下
from mip2.
@jenkey2011
目前 mip-cli 1.0.10 版本支持子组件暴露 custom element 机制,在组件编译的时候,会遍历组件所在文件夹,查找满足命名规则的文件作为子组件自动注入到组件的 bundle js 中,并且自动注册为 custom element,举个例子,组件的文件结构如下:
components/
..mip-example/
....mip-example.vue
....mip-example-child.vue
....mip-test.vue
其中 mip-example.vue 会被识别为组件入口文件,mip-example-child.vue 会被识别为子组件自动注入到编译生成的 mip-example.js 中,而 mip-test.vue 因为不满足命名规则因此不会被识别为子组件。
对于 mip-example-child.vue 和 mip-test.vue 仍然可以像 vue 的组件那样通过传入 mip-example.vue 的 components 属性中进行使用。
子组件命名规则说明
子组件只有在满足以下条件才会被识别为需要注册为 custom element 的组件:
- 子组件必须以
.vue
或.js
后缀结尾 - 子组件与入口组件文件必须处于同一层级
- 子组件文件命名必须按 ${父组件名}-${子组件名} 的格式命名,比如 mip-example.vue -> mip-example-child.vue
from mip2.
Related Issues (20)
- 沙盒开放 document.referrer 读权限
- iframe里的页面mip-fixed组件不再有固定效果(IOS环境) HOT 1
- 怎么停用已经生效的mip HOT 1
- mip-link打开iframe页面无法正确计算高度的问题(IOS12,IOS13环境)
- [sandbox] 申请 swanInvoke
- 反馈:docs/news/index.md
- 反馈:docs/components/dynamic-content/mip-form.md HOT 3
- MIP 头部 bar 固定样式会被网站自自定义样式影响
- mip-video 在安卓qq浏览器脱离文档流
- 反馈:docs/news/index.md HOT 1
- 非白名单 npm 列表 HOT 1
- 反馈:docs/components/layout/mip-tabs.md HOT 1
- 独立域名的mip站点到底如何正确退出,恢复成H5移动站 HOT 1
- 反馈:docs/components/presentation/mip-rem.md HOT 1
- vue 组件在注册的时候会执行两次
- m-bind:href 浏览器上显示 href="{"tel":""}"
- MIP Cache 服务下线,请问这个项目是不维护了吗? HOT 2
- @baidu/fc-jmy-client-capabilities包申请加白
- 官网https://www.mipengine.org/证书过期好几个月了 HOT 1
- mip2+vue怎么配置跳转?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mip2.