跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 使用 uni-app 开发小程序和 H5,分包异步化只能在小程序生效, H5 只能写兼容代码吗?

发表于
原来的小程序中,由于代码比较多,之前做了分包,并且很多地方用了分包异步化来处理。比如富文本渲染用到 wxParse ,写成了一个组件,专门放到了一个分包中,然后通过分包异步化引入其他页面使用。除此之外还有些其他的,比如公用的 iconfont 图标,表单组件,重写的带搜索的 Picker 等,都是通过异步化加载的。

最近需要用 uniapp 来重构,但是使用分包异步化有些问题。
在 uniapp 中的 page.json 中,定义了 usingComponents 和 componentPlaceholder 。编译后,发现无法生成对应分包信息,后面发现需要在对应的分包 pages 中也添加组件的 xxx.vue 的地址,也就是需要当作页面定义好才能正确生成分包并引入。但是此种方法引入的组件,无法在 H5 网页中正确的显示和使用。

有没有什么方法可以直接引入后使用,而无需编写其他的兼容代码?



ps:前段时间还看了下 taro ,taro 的分包异步化只能通过 webpack 打包时处理,自定义组件还需要写成原本的 wxml 这些,然后用 copy 复制。也就是说必须要写兼容代码才行

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.