// 公用组件代码
<template>
<view>
<slot name="title"></slot>
<view v-for="(item, index) in 3" :key="index">
<slot name="content" :row="item"></slot>
</view>
</view>
</template>
// 分包界面代码
<template>
<view>
<child-cmp>
<template #title>123</template>
<template #content="{ row }">
<view>{{ row }}</view>
</template>
</child-cmp>
</view>
</template>
![B丶iang](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/44/12/05_avatar_mid.jpg?v=0)
- 发布:2022-05-12 15:36
- 更新:2024-05-20 09:31
- 阅读:1306
产品分类: uniapp/小程序/字节跳动
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 10 家庭版 20H2
第三方开发者工具版本号: Version: 3.2.7-1 OS: Windows_NT x64 10.0.19042 DeviceId: ebfca2b0-de6d-43a8-aff4-719057712b4f Electron: 11.2.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0
基础库版本号: 2.49.0.9
项目创建方式: CLI
CLI版本号: 4.5.11
示例代码:
操作步骤:
npm run dev:mp-toutiao
npm run dev:mp-toutiao
预期结果:
代码正常运行
代码正常运行
实际结果:
编译错误 主包不能引用分包文件: pages/subPage/subPage--child-cmp--content--97ea.json
at components/ChildCmp.json
编译错误 主包不能引用分包文件: pages/subPage/subPage--child-cmp--content--97ea.json
at components/ChildCmp.json
bug描述:
在添加"scopedSlotsCompiler": "augmented"的情况下,当主包内的公用组件被分包界面引用:
- 使用1个插槽的情况下,打包后公用组件json文件正常,usingComponents下未引入任何文件路径。
- 使用2个插槽的情况下,打包后公用组件json文件的usingComponents下引入了分包界面文件夹下的插槽内容文件,导致主包引用分包文件报错
分包界面:subPage.vue
公用组件:ChildCmp.vue
测试项目已打包上传,npm install之后运行相关编译命令即可
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20220512/ef8b6555401fa4ca83005ea138f99a9d.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20220512/b26ea74e2df73bd8244cf22470098969.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20220512/647b820fdeb950b80d66a2f2cd5c690a.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20220512/af6347863dd7782a57075f77a1811fea.png)