小编Piy*_*han的帖子

如何使用react-native中的图标来建模按钮

我正在使用react-native-icons包来包含带按钮的图标.他们在示例文件夹中列出了示例代码.我正在尝试onPress在View 上实现但事实证明react-native没有组件onPress功能<View>.

我尝试使用<TouchableHighlight>,但只能有一个子元素在它不是两个像<Icon><Text>里面.

我也试过使用<Text>with <Icon><Text>inside但内部<Text>只能有<Text>元素.

有没有人有幸获得类似的功能?

带图标的示例按钮

<View onPress={this.onBooking} 
  style={styles.button}>
  <Icon
    name='fontawesome|facebook-square'
    size={25}
    color='#3b5998'
    style={{height:25,width:25}}/>
  <Text style={styles.buttonText}>Sign In with Facebook</Text>
</View>
Run Code Online (Sandbox Code Playgroud)

javascript ios reactjs react-native

15
推荐指数
3
解决办法
4万
查看次数

错误:不变违规:可触摸的子项必须是本机或转发setNativeProps到本机组件堆栈

我很难应付这个错误.

可触摸的孩子setNativeProps错误

我不明白为什么?我有一个不使用自定义组件的子组件.我将Textor ImageIconin View组件包装起来,然后将它们包装在TouchableHighlight仍然在特定页面上获取错误但不在其他正在执行相同操作的页面上.

    <TouchableHighlight
      onPress={this.changeTo} style={PictureStyles.btnClickContain}
      underlayColor='#042417'>
      <View
        style={PictureStyles.btnContainer}>
        <Icon
          name='fontawesome|calendar'
          size={25}
          color='#042'
          style={PictureStyles.btnIcon}/>
        <Text style={PictureStyles.btnText}>Book</Text>
      </View>
    </TouchableHighlight>
Run Code Online (Sandbox Code Playgroud)

javascript ios reactjs react-native

13
推荐指数
1
解决办法
3999
查看次数

如何从Linux上的命令行访问API文档?

是否有命令从linux命令行访问rust-lang api文档?

我正在为golang文档提供类似于此示例的内容:

godoc strings Contains

它给出了输出:

包装文件

包字符串导入"字符串"

功能

func Contains(s,substr string)bool如果substr在s内,则返回true.

我知道有一个rustdoc命令,但它只生成文档,它不会显示它.

rust

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

如何使用fetch in native native发布表单?

我正在尝试使用react-native fetch api发布包含first_name,last_name,email,password和password_confirmation的表单.

fetch('http://localhost:3000/auth', {
  method: 'post',
  body: JSON.stringify({
    config_name: 'default',
    first_name: this.state.first_name,
    last_name: this.state.last_name,
    email: this.state.email,
    password: this.state.password,
    password_confirmation: this.state.password_confirmation,
  })
})
Run Code Online (Sandbox Code Playgroud)

Rails控制台中的输出

Parameters: {"{\"config_name\":\"default\",\"first_name\":\"Piyush\",\"last_name\":\"Chauhan\",\"email\":\"piyushchauhan2011@gmail.com\",\"password\":\"diehard4\",\"password_confirmation\":\"diehard4\"}"=>"[FILTERED]"}
Unpermitted parameter: {"config_name":"default","first_name":"Piyush","last_name":"Chauhan","email":"piyushchauhan2011@gmail.com","password":"diehard4","password_confirmation":"diehard4"}
Run Code Online (Sandbox Code Playgroud)

因此,它将整个值作为字符串和rails发布,将字符串解析为变量.我想从json响应中删除"{".怎么做 ?

javascript reactjs react-native

8
推荐指数
1
解决办法
1万
查看次数

反应原生导航器在大型应用程序中建模的最佳方式?

我想知道如何使用大型应用程序的react-native的Navigator组件为应用程序建模.我有两种方法:

  • 首先,我们可以使用Navigator组件作为顶级组件,并将props传递给需要导航器对象的每个子组件,或者使用passProps将它们传输到下一个视图,并再次使用props使它们可用于子组件.
  • 其次,人们正在谈论通量架构,他们说触发一些动作并使用该动作来触发下一个视图的导航.这很好,因为我们可以检查各种状态,并将用户重定向或限制到不同的视图,例如loggedIn,loggedOut,Owner等.

我尝试使用第二策略建模导航,触发一些操作并存储监听它并以状态作为有效负载发出更改.然后,我检查导航顶视图组件以检查密钥并使用if语句来触发导航使用this.prop.navigator.push.我遇到的问题是导航器不会更改else if语句.从理论上说,它应该工作,但它不起作用,我不知道.

对于模型一,我遇到了将道具传递下来的问题.太乱了!

有人可以为我提供任何用例的示例模型图或github应用程序吗?

示例代码:

var Navigation = React.createClass({
  mixins: [FluxMixin, StoreWatchMixin("NavigationStore")],
  getStateFromFlux: function() {
    var flux = this.getFlux();

    console.log('Handled the Navigation: ', flux.store('NavigationStore').getState());
    // console.log(this.props.navigator);
    var currentState = flux.store("NavigationStore").getState();
    if(currentState.data.key !== undefined && currentState.data.key.explore !== undefined) {
      this.props.navigator.push({
        id: 'YETANOTHERVIEW',
        title: 'Yet Another View',
        component: SomethingView,
        navigationBar: <NavigationBar title="Something View" />,
        passProps: {
          navigator: this.props.navigator
        }
      });
    } else if(currentState.data.key !== undefined && currentState.data.key.other !== undefined) {
      this.props.navigator.push({
        id: 'OTHERVIEW',
        title: 'Other View',
        component: …
Run Code Online (Sandbox Code Playgroud)

javascript ios reactjs react-native

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

Angular Material mdTabs - 如何只获取标签动画效果而不是内容?

我想获得动画效果,当有人点击标签时,该标签下方的边框向右滑动,按钮具有良好的连锁效果.我不想使用标签内的内容,我只想要标签效果.

mdTabs

如您所见,单击第二个选项卡将使边框向右滑动,但内容也将向左移动.我只希望标签按钮向右滑动,作为我效果的一部分.我怎样才能做到这一点?

javascript angularjs material-design angular-material

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

弃用警告:不推荐使用`Validator#setup`实例方法,将在Rails 4.2中删除

我不知道这个警告是什么?请提出建议.以下是我的应用程序代码的一部分.它使用validates_date行给出了语句错误.

Rails建议我做类似的事情:

class MyValidator < ActiveModel::Validator
  def initialize(options={})
    super
    options[:class].send :attr_accessor, :custom_attribute
  end
end
Run Code Online (Sandbox Code Playgroud)

这是以下的应用程序代码:

class Patient < ActiveRecord::Base
  searchkick index_name: "patients",text_start: [:first_name,:last_name] 
  after_update :reindex
  has_secure_password
  has_many :addresses
  has_many :vitals
  has_attached_file :avatar, :styles => { :medium => "150x150>", :thumb => "50x50>" },   :default_url => "app/assets/images/missing.png"

  validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/

  validates :email, email_format: {message: "Invalid email format" }

  validates_uniqueness_of :email

  validates :password_digest, presence: true, confirmation: true, length: {minimum: 8,message:"Must be of atleast 8 characters"}

  validates :first_name, presence: true, format: { …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails-4

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

Kotlin解构变量不适用于Pair,Triple或数据类

我最近在kotlinc,命令行环境中尝试了以下代码.

var greet = Pair("Hello", "World")
val (word1, word2) = greet
Run Code Online (Sandbox Code Playgroud)

输出word1word2在控制台输出以下消息

>>> word1
error: unresolved reference: word1
word1
^
Run Code Online (Sandbox Code Playgroud)

我不确定是否从最新版本的kotlin中删除了解构.目前,在mac上使用编译器1.0.2版本kotlinc.

java destructuring kotlin data-class

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