GVKun编程网logo

仅在边框的一侧添加边框 React Native(iOS)中的组件

2

针对仅在边框的一侧添加边框ReactNative和iOS中的组件这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展2021年的react-native-mapbox-gl与react-nati

针对仅在边框的一侧添加边框 React NativeiOS中的组件这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展2021 年的 react-native-mapbox-gl 与 react-native-maps、Autolink 不适用于 react-native 0.63.4 和 react-native-localize、ios – React native error – react-native-xcode.sh:line 45:react-native:command not found命令/ bin/sh失败,退出代码127、MobX 和 React Native 功能组件:我们如何在 React Native 功能组件中实现 mobX?等相关知识,希望可以帮助到你。

本文目录一览:

仅在边框的一侧添加边框 React Native(iOS)中的组件

仅在边框的一侧添加边框 React Native(iOS)中的组件

<Text/>iOS中 遇到React-Native 组件的怪异问题。

我想将borderBottomWidth样式应用于<Text/>组件,但是没有用。但是,该borderWidth选项 有效

  • 工作了 <Text style={{borderWidth:1}}> React Native </Text>

  • 不起作用 <Text style={{borderBottomWidth:1}}> React Native </Text>

有什么方法只能将底层边框应用到<Text/>组件中吗?

谢谢!


注意:

我知道以下提到的方法可以实现此目的,但就我而言,我仅需要将样式应用于<Text/>组件。

  1. 我们可以尝试包装<View/><Text/>并将borderBottomWidth样式应用于<View/>。(borderBottomWidth与配合使用<View/>
  2. <View/><Text/>组件的下面添加这样的内容,看起来像一条线。

2021 年的 react-native-mapbox-gl 与 react-native-maps

2021 年的 react-native-mapbox-gl 与 react-native-maps

如何解决2021 年的 react-native-mapbox-gl 与 react-native-maps?

我希望使用 React Native (expo) 构建一个需要渲染地图的应用程序。环顾四周,看起来 react-native-maps 和非官方 MapBox RN 库是两个主要选项。我试着四处寻找两者之间的一些比较,但找不到任何更新的信息。

两者在性能和可定制性方面如何比较?这两个是我最关心的。大多数情况下,我对渲染大量标记感兴趣,可能会利用聚类,以及自定义地图和标记样式。

提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Autolink 不适用于 react-native 0.63.4 和 react-native-localize

尝试通过 npx react-native run-android 命令再次运行项目。

如果您使用的是 iOS 设备,则:

cd ios && pod install npx react-native run-ios 如果仍然无效,请尝试再次安装 npm 包并按照文档进行操作。

,

使用

npx react-native link react-native-localize

代替

react-native link react-native-localize

希望能帮到你

ios – React native error – react-native-xcode.sh:line 45:react-native:command not found命令/ bin/sh失败,退出代码127

ios – React native error – react-native-xcode.sh:line 45:react-native:command not found命令/ bin/sh失败,退出代码127

尝试构建任何(新的或旧的)项目时出现此错误.
我的节点是版本4.2.1,react-native是版本0.1.7.
我看过其他有相同问题的人,所以我已经更新了本机的最新版本,但是我仍然无法通过 xcode构建任何项目.

解决方法

要解决此问题,请使用以下步骤:

>使用节点版本v4.2.1
> cd进入[你的应用] / node_modules / react-native / packager
> $sh ./packager.sh(出于某种原因,运行正常)
>进入XCode并转到Build Phases选项卡.
删除列表中的最后一项(运行脚本的项目).所以你留下了Target Dependencies,Compile Sources,Link Binary With Libraries和copy Bundle Resources.

现在点击XCode中的build.由于shell脚本不再是XCode构建例程的一部分,因此它不应该失败.如果你在另一个终端窗口中运行react本机客户端服务器,那么一切都应运行正常.

MobX 和 React Native 功能组件:我们如何在 React Native 功能组件中实现 mobX?

MobX 和 React Native 功能组件:我们如何在 React Native 功能组件中实现 mobX?

您可以使用不带装饰器的解决方案,而是使用 useLocalObservable 钩子创建本地组件状态:

const Shop = observer(() => {
  const state = useLocalObservable(() => ({
    price: 9,setPrice(price) {
      state.price = price;
    },quantity: 11,setQuantity(quantity) {
      state.quantity = quantity;
    },get total() {
      return state.price * state.quantity;
    },}));

  return (
    <SafeAreaView style={styles.container}>
      <Text>Price: </Text>
      <TextInput value={state.price} onChangeText={state.setPrice} />
      <Text>Quantity: </Text>
      <TextInput value={this.quantity} onChangeText={state.setQuantity} />
      <Text>Total (Price and Quantity): {state.total}</Text>
    </SafeAreaView>
  );
});

const styles = StyleSheet.create({
  container: {
    flex: 1,justifyContent: "center",alignItems: "center",},});
,

这里有一些关于如何在功能组件中使用它的想法。 (注意我没有测试代码,但这是给你方向的)

1.为 Shop Store 创建一个类,应该是这样的。

import { observable,computed,action } from "mobx";

export class ShopStore {

    @observable price;
    @observable quantity;
    
    constructor (value) {
        this.id = 9;
        this.quantity = 11;
    }

    @computed get total() {
        return this.price * this.quantity;
    }

    // Use @action to modify state value
    @action setPrice = (price) => {
        this.price = price;
    }

    // Use @action to modify state value
    @action setQuantity = (quantity) => {
        this.quantity = quantity;
    }
}

2.在你的 App.js 中初始化 Mobx 商店

import React from 'react';
import { ShopStore } from './src/mobx/store';
import ShopComponent from "./src/components/ShopComponent";
function App() {
    const store = new ShopStore()
    return (
        <ShopComponent store={store}/>
    );
}
export default App;

3.将 mobx 观察者连接到功能组件

import { observable,computed } from "mobx";
import { observer } from "mobx-react";
import React from "react";
import { SafeAreaView,Text,TextInput,StyleSheet } from "react-native";

function ShopComponent(props) {

    const { setPrice,setQuantity } = props.store

    return(
        <SafeAreaView style={styles.container}>
            <Text>Price: </Text>
            <TextInput value={props.store.price} onChangeText={value => { setPrice(value) }} />
            <Text>Quantity: </Text>
            <TextInput value={props.store.quantity} onChangeText={value => { setQuantity(value) }} />
            <Text>Total (Price and Quantity): {props.store.total() }</Text>
        </SafeAreaView>
    )
}
export default observer(ShopComponent);

关于仅在边框的一侧添加边框 React NativeiOS中的组件的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于2021 年的 react-native-mapbox-gl 与 react-native-maps、Autolink 不适用于 react-native 0.63.4 和 react-native-localize、ios – React native error – react-native-xcode.sh:line 45:react-native:command not found命令/ bin/sh失败,退出代码127、MobX 和 React Native 功能组件:我们如何在 React Native 功能组件中实现 mobX?等相关内容,可以在本站寻找。

本文标签: