当前位置: 首页 > news >正文

uniapp中使用组件分包

小程序体积限制2M,所以组件跟其他的资源能往分包放置就往分包放置

1.首先配置小程序的分包开启,在manifest.json文件夹下的appid底下写入
mp-weixin:{
appid: 'xxx',//开启分包代码
optimization: {subPackages: true,}
}
2.在pages.json中配置分包页面
{//未分包页面"pages": [{"path": "pages/index","style": {"navigationBarTitleText": "首页",usingComponents: { //主包中使用组件"a-com": "/src/sub-common/components/a-com.vue",},componentPlaceholder: {"a-com": "view",//用view标签占位},}}],// 分包页面"subPackages": [{"root": "sub-common", //文件夹名称"pages": [ {"path": "index","style": {"navigationBarTitleText": "占位分包页", // 建一个vue文件就可以,主要用到components}}]},{"root": "sub-apage","pages": [{path: "index",style: {navigationBarTitleText: "分享页",navigationStyle: "custom",usingComponents: { //分包中使用组件"a-com": "/src/sub-common/components/a-com.vue",},componentPlaceholder: {"a-com": "view",},},},]}]
}
3.在需要使用的页面引入组件,在pages/index.vue 与 sub-apage/index.vue中需要这样引入
<script>
import aCom from "@/sub-common/components/a-com.vue";
</script><template>
<aCom/>
</template>
http://www.dtcms.com/a/265347.html

相关文章:

  • 在Linux服务器上使用kvm创建虚拟机
  • Springboot3.3.4使用spring-data-elasticsearch整合Elasticsearch7.12.1
  • 【Linux仓库】进程优先级及进程调度【进程·肆】
  • vue-38(使用 Cypress 进行端到端测试)
  • 基于微信小程序的学校招生系统
  • 破解风电运维“百模大战”困局,机械版ChatGPT诞生?
  • 第8章网络协议-NAT
  • 机器学习在智能能源管理中的应用:需求响应与可再生能源整合
  • Google Maps 安装使用教程
  • 六、软件操作手册
  • 按月设置索引名的完整指南:Elasticsearch日期索引实践
  • 第五章 局域网基础
  • Spark流水线数据探查组件
  • 部署KVM虚拟化平台
  • odoo17 警示: selection attribute will be ignored as the field is related
  • centos7下源码编译ffmpeg时报错ERROR opus not found using pkg-config问题修复
  • 全角半角空格在网页中占位符和编码emsp;ensp;
  • 网络协议概念与应用层
  • 深度解析Elasticsearch滚动索引:原理、实践与自动化管理
  • Spring cloud gateway
  • C++2d我的世界V1.4
  • 模型预测专题:强鲁棒性DPCC
  • 智能检测原理和架构
  • 哪个领域数据库最难替换?
  • Softhub软件下载站实战开发(十):实现图片视频上传下载接口
  • rockchip android14 设置不休眠
  • 数学建模_微分方程
  • 商品中心—18.库存分桶的一致性改造文档
  • RedisCluster不可用的6大隐患
  • 通俗理解JVM细节-面试篇