Giter Club home page Giter Club logo

Comments (4)

clark-t avatar clark-t commented on July 30, 2024

在目前现有的组件构建方案里面,可以考虑把 mip-vd-tabs 和 vd-tab 分别弄成两个组件 在 html 里引入即可达到你想要的效果

from mip2.

jenkey2011 avatar jenkey2011 commented on July 30, 2024

@clark-t 单独开发两个组件确实可以,有俩问题

  • 两个是配套的组件,但是需要分别引入两个js文件,关联性太低,提测、管理、上线,都比较麻烦
  • 如果一个组件需要拆分成三个五个,那这无疑增加了组件的数量,想想mip1,700+的站长组件……

from mip2.

PengXing avatar PengXing commented on July 30, 2024

这个问题的解决方案呢?节前其实已经有结论了, @clark-t 这个可以写一下

from mip2.

clark-t avatar clark-t commented on July 30, 2024

@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 的组件:

  1. 子组件必须以 .vue.js 后缀结尾
  2. 子组件与入口组件文件必须处于同一层级
  3. 子组件文件命名必须按 ${父组件名}-${子组件名} 的格式命名,比如 mip-example.vue -> mip-example-child.vue

from mip2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.