把一个Vue项目的页面打包后再另一个项目中使用

步骤:

1.项目1新建一个js文件,引入我们需要使用的vue页面:

// 引入组件
import indexVue from './index.vue'

// install
indexVue.install = function (Vue) {
  Vue.component("indexVue", indexVue)
  // Vue.component(FlowEditorVue.name, FlowEditorVue)
}


// 导出
export default indexVue


2.在项目1的package.json中添加命令将刚才导出的vue页面进行打包;

"lib": "vue-cli-service build --mode prod --target lib --name indexVue --dest lib src/views/workflow/work/index.js"

3.在你需要使用的项目中将打包后的lib目录放在项目2的public目录下;


4.然后再项目2的main.js文件中引入我们lib中的common.js并使用它;

import indexVue from '../public/lib/indexVue.common.js'
Vue.use(indexVue)



5.再我们的项目2的页面中直接使用它;
 

<template>
  <div class="app-container">
    <index-vue></index-vue>
  </div>
</template>
<script>

export default {
  name: 'WorkProcess',

  data() {
    return {}

  },
}
</script>

<style scoped>

</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值