We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述
自定义组件,通过 properties 接收外部传参,构建为多平台小程序后,properties 并没有绑定在 this 上,但微信小程序还能通过 this.properties 和 this 访问,而支付宝小程序只能通过 this.props 和 this 来访问
properties
this.properties
this
this.props
期望表现
因为是之前的代码迁移,大部分写法都是通过 this.properties 这种形式来访问,所以希望构建为支付宝后也能通过 this.properties 来获取到
The text was updated successfully, but these errors were encountered:
this.properties访问数据在微信小程序文档中没有相关用法说明,目前开发者工具实测this.properties和this.data指向同一个对象,里面不止包含properties数据也包含data数据,目前对于微信原生组件输出支付宝时mpx抹平了的this.data中能够访问props数据的表现,但这种抹平修改了组件实例的内部数据可能存在潜在风险,所以安全和必要性角度考虑.mpx组件在跨端输出时没有该抹平,对于.mpx组件来说标准的数据访问方式是通过this来进行访问,这种方式框架可以保障跨平台一致性,建议业务代码也统一修改为该方式
Sorry, something went wrong.
那可不可以提供一种方式,让开发者可以手动赋值呢,比如提供一个配置,可以吧this.props的数据赋值给this.properties?
可以的,你可以全局mixin,在BEFORECREATE钩子里去做这个抹平,示例如下:
import mpx, {BEFORECREATE} from '@mpxjs/core' mpx.mixin({ [BEFORECREATE](){ this.properties = this.properties || this.props } })
No branches or pull requests
问题描述
自定义组件,通过
properties
接收外部传参,构建为多平台小程序后,properties 并没有绑定在 this 上,但微信小程序还能通过this.properties
和this
访问,而支付宝小程序只能通过this.props
和this
来访问期望表现
因为是之前的代码迁移,大部分写法都是通过
this.properties
这种形式来访问,所以希望构建为支付宝后也能通过this.properties
来获取到The text was updated successfully, but these errors were encountered: