小编fli*_*lix的帖子

React Native - 我们可以将图像和文本共享到whatsapp吗?

我花了一个小时的时间来找到一种方法来发送/共享一个图像(如果可能的话,还有文本)到whatsapp应用程序中使用react native,

我已经读过这个问题(在android中)和这个问题(使用链接)

在Android上,有可能将图像和文本发送到whatsapp,但在本机上我没有看到任何方法来实现它,

有谁有想法?

image whatsapp react-native

8
推荐指数
2
解决办法
8188
查看次数

如何在没有第 3 方库的情况下在 React Native 中创建 3x3 网格菜单?

我想在 React Native 中创建网格中心菜单,我刚刚阅读了文档并且看起来不错,但是我在为每个网格菜单创建行时遇到了问题

我已经使用复制粘贴代码创建了 3x3 网格 flexbox:

<View style={{
        flexDirection: 'row',
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
      }}>
        <View>
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, marginLeft:10, backgroundColor: 'powderblue'}} />
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, marginLeft:10, backgroundColor: 'skyblue'}} />
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, marginLeft:10, backgroundColor: 'steelblue'}} />
        </View>
        <View>
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, marginLeft:10, backgroundColor: 'powderblue'}} />
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, marginLeft:10, backgroundColor: 'skyblue'}} />
          <View style={{width: DeviceWidth*0.2, height: DeviceWidth*0.2, marginBottom:10, …
Run Code Online (Sandbox Code Playgroud)

css grid-layout react-native

6
推荐指数
1
解决办法
6202
查看次数

React Native-W / unknown:InspectorPackagerConnection:无法连接到打包程序,将以静默方式重试

我试图在Android上运行我的React Native,从其余API获取数据时一切看起来都不错,

但是我不知道为什么当我想将数据发送到REST API时,控制台日志告诉我

W/unknown:InspectorPackagerConnection: Couldn't connect to packager, will silently retry

这是我尝试过的代码:

try {
  console.log(Constants.APILink + `DoAudit/PostCompleteAuditSchedulev1`, header + `token`)
  axios.post(Constants.APILink + `DoAudit/PostCompleteAuditSchedulev1`, header, {
    headers: {
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Authorization": "Bearer " + Queries.getPersistentData('token')
    }
  })
// NEVER RUN TO THIS STATEMENT OR SHOWING ME AN ERROR IN LOGCAT
    .then(res => {
      if (res.data == 0) {
        console.log("Upload success HEADER");

        var path = '/storage/emulated/0/Documents' + '/testx.txt';
        RNFS.writeFile(path, JSON.stringify(mediaListFinding + auditid), 'ascii')
          .then((success) => {
            console.log('FILE WRITTEN!');
            let …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-android

5
推荐指数
0
解决办法
1203
查看次数

React Native - 如何在执行函数之前处理 TextInput onChangeText 事件以等待?

我有一个在 React Native 中使用文本输入的搜索功能,但是搜索需要调用一个 API,所以我想onChangeText在用户完成输入 2 秒后保持运行,

我试过使用setIntervalsetTimeout但这些都不起作用,

这是我试过的代码:

<TextInput
  placeholder="search"
  onChangeText={(text) => {
    setTimeout(() => {
      console.log(text)
      console.log("Kepanggil TimeOUTNYAA")
      params.onSearchText(text)
    }, 2000);
  }
}

//function onSearchText

onSearchText(searchText){
  this.setState({text:searchText},()=>{
    this._loadMore() // here's a function to call the API
  })
}
Run Code Online (Sandbox Code Playgroud)

实际行为:

当我键入amTextInput日志显示我:

实际的

预期行为:

我希望日志 显示我am aam

有可能做到吗?

javascript textinput react-native

5
推荐指数
2
解决办法
4618
查看次数

Cannot access this.props from string to function

I want to know why i can use this.props directly but i can't use this.props from string into function.

the error is:

undefined is not an object (evaluating 'this.props.navigation')

here a sample code i've tried:

state={
  stringToFn="this.props.navigation.navigate(\'otherscreen\')",
  stringToFn2="alert(\'otherscreen\')"
}

renderThis(){
  let nyobaFunc = new Function("return " + "()=>{"+this.state.stringToFn+"}")();
  return(
    <TouchableOpacity onPress={nyobaFunc} style={styles.flatListButton}>
      <CustomText style={styles.flatListSubTitle}>{'HitMe!'}</CustomText>
    </TouchableOpacity>
  )
}

render(){
  return(
    {this.renderThis()}
  )
}
Run Code Online (Sandbox Code Playgroud)

but if i put stringToFn value into onPress directly or if i change this.state.stringToFn to this.state.stringToFn2 in …

javascript reactjs react-native

5
推荐指数
1
解决办法
83
查看次数

React Native - Alert 组件方法中的“类型”意味着什么?

我是 React Native 的新手,当我阅读有关Alert组件的内容时,我看到了有关alert方法static alert(title, message?, buttons?, options?, type?)

facebook 给出的例子:

Alert.alert(
   //Title
  'Alert Title',
   //Message
  'My Alert Msg', 
   //Button
  [
    {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
    {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
    {text: 'OK', onPress: () => console.log('OK Pressed')},
  ],
   //Options
  { cancelable: false } 
)
Run Code Online (Sandbox Code Playgroud)

并且没有关于做什么的例子type,有人可以告诉我这些是什么type

有没有办法显示Alert没有Title

alert react-native

4
推荐指数
1
解决办法
2892
查看次数

是否有可能在ES6上处理2变量if/else条件是否为真?

假设我有这样的代码

var a, b;
b = 1;
var c = b > 0 ? a = 1 /*and c = 2*/ : a = 0 /*and c = 1*/;
console.log(a + c);
Run Code Online (Sandbox Code Playgroud)

有没有办法制作c = 2a = 1使用上面的代码?

javascript if-statement ecmascript-6

3
推荐指数
1
解决办法
61
查看次数

如何在flutter中动态设置State变量?

我刚刚开始学习flutter,我很好奇如何setState()动态地在flutter中

React Native通常使用这样的函数来setState动态地:

class foo extends React.Component{
  state={
    username:null,
    password:null
  }

  toggleSetState(whatState, value){
    this.setState({ [whatState]: value })
  }

  render() {
    return (
      <View>
        <TextInput
          value={this.state.username}
          onChangeText={(text)=>{toggleSetState(username, text)}
        />
        <TextInput
          value={this.state.password}
          onChangeText={(text)=>{toggleSetState(password, text)}
        />
      </View>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

与上面的代码等效的是什么Flutter

我已经尝试过,Flutter但似乎不起作用

class _LoginFormState extends State<LoginForm> {
  String username, password;

  void ToogleState(typedata, text){
    setState(() {
      typedata = text;
    });
  }

  //Widget
  TextField(
    onChanged: (text){ToogleState(username, text); print(username);},
    decoration: InputDecoration(
      hintText: 'input username', labelText: 'Username' …
Run Code Online (Sandbox Code Playgroud)

dart flutter

3
推荐指数
1
解决办法
7574
查看次数

如何以编程方式更改其子项中 main.dart AppBar 的标题?

我有一个AppBar输入main.dart,我想将它定义为它的孩子的主要内容,但是AppBar当我在孩子的页面上时,我想更改它自己的标题,我该如何正确地做到这一点?

void main() => runApp(MyApp());

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter App",
      theme: ThemeData(
        primaryColor: Colors.cyan,
        brightness: Brightness.dark
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Main Dart"),
        ),
        body: HomeScreen(),
      ),
      routes: <String, WidgetBuilder>{
        '/homeScreen': (buildContext)=>HomeScreen(),
        '/second': (buildContext)=>Second() 
      },
    );
  }
}

//HomeScreen or Second Widget on different dart file

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //here I want to change the title …
Run Code Online (Sandbox Code Playgroud)

appbar dart flutter

3
推荐指数
1
解决办法
3490
查看次数

反应原生 - 带有百分比值的 paddingTop 不起作用

参考react native padding top doc

paddingTop 的工作方式类似于 CSS 中的 padding-top。有关更多详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top

css 链接上,padding-top 有一些百分比,但它在本机反应中不起作用,

如何在 paddingTop 反应原生中添加百分比?

react-native

2
推荐指数
1
解决办法
3298
查看次数