Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支付宝小程序内的 web-view 属性无法动态更新 #18

Closed
elcarim5efil opened this issue Nov 1, 2018 · 1 comment
Closed

支付宝小程序内的 web-view 属性无法动态更新 #18

elcarim5efil opened this issue Nov 1, 2018 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@elcarim5efil
Copy link
Member

原生支付宝小程序在使用 web-view 组件时,src 属性只能在,页面初次渲染完成前进行更新。即必须在 onReady 触发以前。

<web-view src="{{url}}" onMessage="onmessage"></web-view>
Page({
  data: {
    url: 'xxx' // 有效
  },
  onLoad() {
    this.setData({ url: 'aaa' }) // 有效
  },
  onReady() {
    this.setData({ url: 'bbb' }) // 无效
  }
})

目前,megalo 的 $mount 的触发时机是在 onReady 触发时,此时才会首次将 vnode 上的数据同步到小程序视图层,使得 web-viewsrc 无法修改。

  1. 支付宝小程序 wev-view 属性后期是否有可能支持动态绑定(微信小程序是 ok 的,如果官方支持 megalo 就不修改了)
  2. 将数据更新的时机提前到 onLoad 阶段。本身不需要操作 DOM 节点,只是同步数据,所以实现上将 $mount 提前到 onLoad 阶段执行是没什么问题的,但这样的修改会改变生命周期钩子的顺序(onLoad -> created -> mounted -> onReady)。有待验证其影响。
@elcarim5efil elcarim5efil self-assigned this Nov 2, 2018
@elcarim5efil elcarim5efil added the bug Something isn't working label Nov 2, 2018
@elcarim5efil elcarim5efil added this to the 0.3.0 milestone Nov 13, 2018
@elcarim5efil
Copy link
Member Author

megalo@0.3.0
@megalo/template-compiler@0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant