Giter Club home page Giter Club logo

child-desc's Introduction

子项目模版

子项目的最终形态应该只有一个入口文件:app.js,也就是未打包前的main.js

子项目是不需要容器 index.html 的,它是以路由的形式,"寄生"在父级的 router-view 中。

所以,落地到实际的点上,分为开发时和打包后。

开发时

我们需要做到与平时独立开发应用无区别、无感知、无侵入、无依赖。所以

  • devServer 必须有且仅有一个,这样才能保持热更新
  • 子项目只需关注项目内的需求及文件
  • 子项目也能共用全局 store 、能跳转到另一个子项目的路由,也就是说 Vue 实例有且仅有一个

当 Vue 实例全局唯一,那么父级所注册的组件、挂载到 prototype 上的属性或方法,在运行时 this 上都能获取。

打包

要做到"去容器",我们只需在打包时将 index.html 及父级依赖去除再打包即可。

通过 Vue 插件实现

我们可以通过 vue-cli-plugin-micro 来帮助实现上述功能。

子项目开发流程

通过 micro-structure-cli 创建子项目

# 初始化选择子项目
micro init

安装 vue 插件

vue add micro

启动本地服务

npm run serve

child-desc's People

Contributors

jmingzi avatar

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.