For Vue projects, load asynchronous modules through remote links.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build fix Naming errors Oct 31, 2017
config push Oct 11, 2017
src fix Naming errors Oct 31, 2017
static fix Naming errors Oct 31, 2017
.babelrc push Oct 11, 2017
.editorconfig push Oct 11, 2017
.eslintignore push Oct 11, 2017
.eslintrc.js push Oct 11, 2017
.gitignore push Oct 11, 2017
.postcssrc.js push Oct 11, 2017
AsyncComponent.min.js fix Naming errors Oct 31, 2017
LICENSE 修改readme Oct 13, 2017
README.md 修改readme Oct 13, 2017
SyncComponent.min.js fix Naming errors Oct 31, 2017
index.html push Oct 11, 2017
package.json fix Naming errors Oct 31, 2017
yarn.lock 修改test环境引入方式,补全readme Oct 13, 2017

README.md

vue-async-component 异步远端组件

Version License Downloads


用于 vue 项目中通过远程链接加载异步模块(异步模块不随项目一同打包), 依赖 vue v2.4+

Attributes

参数 说明 类型 可选值 默认值
url 组件远程地址 string

Installation

npm:

  npm i vue-async-component -S

基于Node.js的开发环境:

  import SyncComponent from 'vue-async-component';

  <sync-component
    url="http://localhost:8083/static/app.js">
  </sync-component>

浏览器环境:

  <script type="text/javascript" src="SyncComponent.min.js"></script>
  <script type="text/javascript">
    Vue.use(SyncComponent);
  </script>

注意:vue组件没有什么特别限制,唯独在webpack打包过程中需要注意引入项目是否包含当前组件中的依赖,如果有需要排除掉依赖,webpack 配置输出采用 libraryTarget: "var",并且关闭 UglifyJsPlugin 的压缩功能 compress: false, vue-loader v13+ 需要配置 options{ esModule: false }