微信小程序常见的开发问题汇总
1. coverview 中的强制换行
.wrap{ word-break: break-all; word-wrap:break-word; white-space:pre-line;}
2. IOS 阻止页面弹性橡皮筋效果
// taro 为例import Taro, { Component, Config } from '@tarojs/taro';export default class HomePage extends Component { config: Config = { navigationBarTitleText: '首页', disableScroll: true, // 这一句 };}
3. 组件之间的通信方法传递,taro 中需要方法名为 on 开头
container.js
import Child from 'child';render(){ return <View> <Child onToggle={this.handleToggle.bind(this)}/> </View>}
child.js
handleClick(){ this.props.onToggle();}render(){ return <View onClick={this.handleClick.bind(this)}>点击测试</View>}
4. 微信小程序地图
state = { scale : 10}resetScale(){ this.setState({ scale:this.state.scale===10?10.00001:10 })}render(){ return ( <Map scale={this.state.scale}/> )}
Taro.getLocation({ type:'gcj02' // 这里}).then(res=>{ let { longitude, latitude } = res;})
推荐教程:《微信小程序》