小编Kad*_*zaz的帖子

ReactJs 安全性

I have just started learning authorization and authentication in react, and I'm writing this after finishing my first simple login system using JWT, as most of you know you store a token in the browser and then you compare it with the saved tokens in your backend now when that validation is done truly I set Authenticated Boolean to true and gain access to the website, after finishing that simple system I checked react dev tools and I found out …

security web reactjs

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

React setState不是函数

    fileChangedHandler = event => {
    event.preventDefault();
    event.persist();
    new ImageCompressor(event.target.files[0], {
    quality: .6,
    success(result) {
      this.setState({selectedFile: result})
    },
    error(e) {
      console.log(e.message);
    },
  });
  }
Run Code Online (Sandbox Code Playgroud)

这就是上面的功能,我想在成功后改变状态,但我得到了 setState is not a function

这就是我触发它的方式:

<input style={{display: 'none'}} type="file" onChange={this.fileChangedHandler} ref={fileInput => this.fileInput = fileInput}/>
<button type='button' onClick={() => this.fileInput.click()} className='col m3 btn' style={{textTransform: 'none'}}>Choose image</button>
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

GridView 项起床

我有这个问题,而您可以在图像中看到,即使我添加了“layout_below”,项目仍然在很远的地方,我不知道它为什么会发生或如何修复它,我可以通过添加填充来部分修复它,但我不想用这种方法修复,我想要一个通用的修复

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ShoppingPackage.ProductsListActivity">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="16dp"
    android:id="@+id/IntroLayout">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:text="@string/browse"
        android:textSize="36sp"
        android:textColor="@android:color/black"
        android:id="@+id/welcome_back"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/welcome_back"
        android:text="@string/products_list"
        android:textColor="@android:color/black"
        android:textSize="12sp"
        android:id="@+id/categoryName"/>



</RelativeLayout>


<GridView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/IntroLayout"
    android:id="@+id/productsrecycler"
    android:background="#3C3C3C"
    android:numColumns="2"/>

 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是第二个 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="5dp"
app:cardElevation="10dp"
app:cardBackgroundColor="#222222">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="180dp"
        android:layout_height="180dp"
        android:id="@+id/productImageView"
        android:scaleType="fitXY"
        android:layout_centerHorizontal="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/product_name"
        android:id="@+id/productName"
        android:layout_below="@id/productImageView"
        android:layout_centerHorizontal="true"
        android:textSize="18sp"
        android:textColor="@android:color/white"/>


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/product_price"
        android:id="@+id/productPrice"
        android:layout_below="@id/productName"
        android:layout_centerHorizontal="true"
        android:textColor="@android:color/white" />


</RelativeLayout>



</android.support.v7.widget.CardView> …
Run Code Online (Sandbox Code Playgroud)

android android-layout

-1
推荐指数
1
解决办法
48
查看次数

标签 统计

reactjs ×2

android ×1

android-layout ×1

javascript ×1

security ×1

web ×1