jt-micro-components
v0.5.0
Published
远程组件工具库
Downloads
2
Keywords
Readme
jt-micro-components
前端远程组件引入工具包,适用于vue2和vue3
使用步骤
- 安装
npm install jt-micro-components -S
- 在
main.js
里引入依赖和注册全局组件
import jtMicroComponents from 'jt-micro-components';
Vue.use(jtMicroComponents);
- 使用
<micro-components>
标签引入远程组件
<template>
<micro-components moduleName="common-feedback" :data="{ requester, config }" :url="url" />
</template>
<script>
import { GET, POST } from '@/request/axios';
const path = location.pathname.split('/').slice(0, -1).join('/');
const localUrl = 'http://localhost:8088/common-components';
const remoteUrl = `${location.origin}${path}/common-components`;
const url = process.env.NODE_ENV === 'development' ? localUrl : remoteUrl;
export default {
name: 'common-feedback-remote',
data() {
return {
requester: { GET, POST },
config: {},
url,
};
},
};
</script>