Taro: 请问Taro现在支持ref的回调引用吗??

Created on 25 Jul 2018  ·  5Comments  ·  Source: NervJS/taro

问题描述
[请问Taro现在支持ref的回调引用吗??]

*复现步骤

import Taro, { Component } from '@tarojs/taro'
import { View,Image} from '@tarojs/components'
export default class Detail extends Component {
   constructor(props){
     super(props);
     this.content =null;
     this.domRef = element=>{
       this.content = element;
     }
   }
   onScrolltoupper(){
      console.log(this.content);
   }
   render(){
     <ScrollView scrollY
            scrollWithAnimation
            scrollTop='0'
            style='height: 150px;'
            upperThreshold='20'
            onScrolltoupper={this.onScrolltoupper}>
            <View ref={this.domRef} ClassName="example">123</View>
      </ScrollView>
   }
}

期望行为
[期望打印出当前DOM节点信息]

报错信息

[打印出null]

系统信息

  • 操作系统: [Windows 10]
  • Taro 版本 [v.0.0.69]
  • Node.js 版本 [ v8.11.1]

All 5 comments

现在还不能支持

如果想对dom元素添加动态样式该怎么做?文档好像没有提及?尝试了很多种方法,好像都会报错

@Harhao https://nervjs.github.io/taro/native-api.html#wxml%E8%8A%82%E7%82%B9%E4%BF%A1%E6%81%AF
可以使用这个

@luckyadam 打不开你发的网址哎

Was this page helpful?
0 / 5 - 0 ratings