导航

    Taro 社区

    Taro

    • 注册
    • 登录
    • 搜索
    • 版块
    • 最新
    • 话题
    • 热门
    • 群组
    1. 主页
    2. jd_6e3247fdcd239
    J
    • 资料
    • 关注
    • 粉丝
    • 主题
    • 帖子
    • 最佳
    • 群组

    jd_6e3247fdcd239

    @jd_6e3247fdcd239

    0
    声望
    5
    帖子
    783
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    jd_6e3247fdcd239 关注

    jd_6e3247fdcd239 发布的帖子

    • RE: taro scrollIntoView 跳转对应id 视图 无效

      好的,明白了,多谢大佬指点

      发布在 微信小程序
      J
      jd_6e3247fdcd239
    • RE: taro scrollIntoView 跳转对应id 视图 无效

      可以了,非常感谢

      发布在 微信小程序
      J
      jd_6e3247fdcd239
    • RE: taro scrollIntoView 跳转对应id 视图 无效

      还是无效 785ad224-8a90-4350-85a7-689a345d3948-image.png

      发布在 微信小程序
      J
      jd_6e3247fdcd239
    • RE: taro scrollIntoView 跳转对应id 视图 无效

      微信小程序端 删除线
      .scrollview{
      margin-top: 100px;
      white-space: nowrap;
      width: 100%;
      height:5000px;
      }
      .toolBar{
      position: fixed;
      top:0;
      display: flex;
      justify-content: space-around;
      width: 100%;
      z-index: 999;
      background: #fff;
      .tag{
      display: block;
      width: 25%;
      text-align: center;
      }
      }

      js代码:
      import Taro, { Component } from '@tarojs/taro'
      import { View, ScrollView} from '@tarojs/components'
      import './index.less'

      export default class Position extends Component {
      constructor(props) {
      super(props);
      this.state = {
      viewId:"A",
      scrollTop:0,
      list:[
      {
      id:"A",
      name:'A'
      },
      {
      id:"B",
      name:'B'
      },
      {
      id:"C",
      name:'C'
      },
      {
      id:"D",
      name:'D'
      }
      ]
      }
      }

      setView(item){
      console.log(item);
      let id = item.id;
      this.setState({
      viewId:id
      });
      }
      render() {
      console.log(this.state.viewId);
      return (
      <View>
      <View className="toolBar">
      {this.state.list.map(item =>{
      return (
      <View className="tag" key={item.id} onClick={this.setView.bind(this,item)}>{item.name}</View>
      )
      })}
      </View>

        <ScrollView
          className="scrollview"
          scrollX = {true}
          scrollIntoView={this.state.viewId}
        >
          <View id='A' style='height:500px;background:red'>A</View>
          <View id='B' style='height:500px;background:green'>B</View>
          <View id='C' style='height:500px;background:red'>C</View>
          <View id='D' style='height:500px;background:green'>D</View>
          <View id='E' style='height:500px;background:red'>E</View>
          <View id='F' style='height:500px;background:green'>F</View>
          <View id='G' style='height:500px;background:red'>G</View>
          <View id='H' style='height:500px;background:green'>H</View>
          <View id='I' style='height:500px;background:red'>I</View>
          <View id='J' style='height:500px;background:green'>J</View>
        </ScrollView>
      </View>
      )
      

      }
      }

      发布在 微信小程序
      J
      jd_6e3247fdcd239
    • taro scrollIntoView 跳转对应id 视图 无效

      31e438aa-b842-4a5a-948f-f3b08cf9447a-image.png 1d12ae95-c272-43da-845e-7949540d8bd3-image.png

      发布在 微信小程序
      J
      jd_6e3247fdcd239