d***@163.com
d***@163.com
  • 发布:2024-08-08 11:14
  • 更新:2024-08-08 11:28
  • 阅读:99

请问vue2版本cli模式支持跨分包引用js文件吗

分类:uni-app

请问现在cli模式下支持小程序官方的分包引用js方法吗,如果有,麻烦在官方文档加上使用方法
微信小程序官方文档

require('../subPackageB/utils.js', utils => {  
  console.log(utils.whoami) // Wechat MiniProgram  
}, ({mod, errMsg}) => {  
  console.error(`path: ${mod}, ${errMsg}`)  
})  
// 或者使用 Promise 风格的调用  
require.async('../commonPackage/index.js').then(pkg => {  
  pkg.getPackageName() // 'common'  
}).catch(({mod, errMsg}) => {  
  console.error(`path: ${mod}, ${errMsg}`)  
})

依赖版本

{  
"dependencies": {  
    "@dcloudio/uni-app": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-app-plus": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-h5": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-i18n": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-360": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-alipay": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-baidu": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-jd": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-kuaishou": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-lark": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-qq": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-toutiao": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-vue": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-weixin": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-mp-xhs": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-quickapp-native": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-quickapp-webview": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-stacktracey": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-stat": "^2.0.2-3080720230703001",  
    "@vue/shared": "^3.0.0",  
    "aegis-mp-sdk": "^1.24.55",  
    "core-js": "^3.8.3",  
    "cos-wx-sdk-v5": "^1.0.10",  
    "flyio": "^0.6.2",  
    "vue": ">= 2.6.14 < 2.7",  
    "vuex": "^3.2.0"  
  },  
  "devDependencies": {  
    "@dcloudio/types": "^3.3.2",  
    "@dcloudio/uni-automator": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-cli-i18n": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-cli-shared": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-helper-json": "*",  
    "@dcloudio/uni-migration": "^2.0.2-3080720230703001",  
    "@dcloudio/uni-template-compiler": "^2.0.2-3080720230703001",  
    "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.2-3080720230703001",  
    "@dcloudio/vue-cli-plugin-uni": "^2.0.2-3080720230703001",  
    "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.2-3080720230703001",  
    "@dcloudio/webpack-uni-mp-loader": "^2.0.2-3080720230703001",  
    "@dcloudio/webpack-uni-pages-loader": "^2.0.2-3080720230703001",  
    "@vue/cli-plugin-babel": "~5.0.0",  
    "@vue/cli-service": "~5.0.0",  
    "babel-plugin-import": "^1.11.0",  
    "cross-env": "^7.0.2",  
    "jest": "^25.4.0",  
    "mini-types": "*",  
    "miniprogram-api-typings": "*",  
    "postcss-comment": "^2.0.0",  
    "sass": "^1.65.1",  
    "sass-loader": "^13.3.2",  
    "vue-template-compiler": ">= 2.6.14 < 2.7"  
  },  
}
2024-08-08 11:14 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

  • d***@163.com (作者)

    所以是官方还没有完全支持吗

    2024-08-08 11:50

  • DCloud_UNI_yuhe

    回复 d***@163.com: 分包本来就要求不可以挎包调用,要不然要分包干什么

    2024-08-08 11:53

要回复问题请先登录注册