您的位置 首页 技术

微信小程序常见的开发问题汇总

1. coverview 中的强制换行 .wrap{ word-break: break-all; word-wrap:break-word; white-space:pre-li…

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. 微信小程序地图

  • 在用户手动缩放地图时,不会自动触发 scale 的变化,如果要将地图缩放到初始大小,scale 值是没有变化的,不会触发页面更新;此时可以略微改变一下 scale 值,加上一个很小的数,如 0.000001
state = {    scale : 10}resetScale(){    this.setState({        scale:this.state.scale===10?10.00001:10    })}render(){    return (        <Map scale={this.state.scale}/>    )}
  • 地图定位不准的问题,尝试使用 gcj02 坐标
Taro.getLocation({    type:'gcj02' // 这里}).then(res=>{    let { longitude, latitude } = res;})

推荐教程:《微信小程序》

以上就是微信小程序常见的开发问题汇总的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/86163.html

为您推荐

返回顶部