CoverView不是小程序的原生组件吧,我的意思是taro的CoverView可以封装支持下扩展运算符,编译小程序的cover-view组件就可以啊。
15101148736_p
@15101148736_p
15101148736_p 发布的帖子
-
RE: 自定义组件中不支持扩展运算符问题,急!
-
RE: h5编译报错,TypeError: Cannot read property 'isWatch' of undefined
我也遇到过该问题,跟平台系统没关系,我的也是mac。问题出现在taro的cli工具和项目的taro依赖版本没有对上,你检查一下你的cli版本,跟项目依赖的版本
-
利用Children与组合兼容小程序slot槽机制,微信小程序、百度小程序渲染有问题
//Modal.js class Modal extends Component { static defaultProps = { maskTapAble: false, modalVisible: false } //配置全局样式覆盖 static options = { addGlobalClass: true } constructor(props) { super(props) } componentDidMount() { let { modalVisible } = this.props this.setState({ modalVisible: modalVisible }) } handleClose = (maskTapAble, e) => { if (maskTapAble) { } } render() { let { maskTapAble, modalVisible, className } = this.props return ( <CoverView className={classnames("modal-outer",`${className}`, { "visible": modalVisible })}> <CoverView className="modal-mask" onClick={this.handleClose.bind(this, maskTapAble)} ></CoverView> <CoverView className="modal-content"> {this.props.children} </CoverView> </CoverView> ) } } export default Modal
此为外壳代码,
//paySelect.js class PaySelect extends Component { static defaultProps = { visible: false } render() { let { visible, onCancel } = this.props return ( <Modal modalVisible={visible} className="pay-select"> <CoverView className="pay-title"> <CoverView className="cancel" onClick={onCancel}>取消</CoverView> <CoverView className="pay-title-text">选择支付方式</CoverView> </CoverView> <CoverView className={classnames("pay-type-item")}> 企业支付 </CoverView> <CoverView className={classnames("pay-type-item")}> 支付宝 </CoverView> <CoverView className={classnames("pay-type-item")}> 微信支付 </CoverView> <CoverView className={classnames("pay-type-item")}> 百度支付 </CoverView> </Modal> ) } } export default PaySelect
此为children代码
然而在各个小程序的编译代码不一样,导致渲染结构不一致,支付宝小程序的如下
而微信小程序与百度小程序的就有问题,如下:
-
自定义组件中不支持扩展运算符问题,急!
为什么不支持rest property语法呢,这个相当好用啊,而且官方封装的组件里头也用到,说明是很方便的。编译H5可以,编译小程序就报这错!
-
this.props 不支持使用 rest property 语法
为什么不支持rest property语法呢,这个相当好用啊,而且官方封装的组件里头也用到,说明是很方便的。编译H5可以,编译小程序就报这错!
-
原生微信小程序转Taro,然后用Taro转H5,this.setData没有转换成this.setState,导致H5运行找不到setData方法
原生微信小程序转Taro,然后用Taro转H5,this.setData没有转换成this.setState,导致H5运行找不到setData方法
-
Taro项目启动H5开发模式运行不起来
Taro项目启动H5开发模式,运行npm run dev:h5,抛出错误:
(node:2498) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'isWatch' of undefined
(node:2498) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled willterminate the Node.js process with a non-zero exit code.检查发现是在webpack-runner包里头抛出来的,
这里的config为undefined。