小编G. *_*ide的帖子

如何嵌套场景并在React Native Router Flux中使用direction ='vertical'进行导航?

我想嵌套react-native-router-flux <Scene/>并尝试以下方法,但我无法导航到<Scene component={Home}/>from <Scene component={Profile}/>:

<Scene
  component={Home}
  initial={true}
  key='home'
  title='Home'
  type='reset'
>
    <Scene
      component={Profile}
      direction='vertical'
      key='sell'
      title='Sell'
    />
</Scene>
Run Code Online (Sandbox Code Playgroud)

我想在Profile组件内嵌套组件Home,因为它只能通过Home组件访问.

那么如何才能正确地将Profile组件嵌入Home组件中呢?

当我也导航到Profile组件时,它会导航到vertical方向,但是当它尝试导航到另一个Actions.test()没有direction='vertical'设置的组件(例如)Profile时,它应该从组件导航到它应该是垂直的时水平导航,而在Profile组件中按下后退按钮随着vertical方向向后航行.

由于我导航到Profile组件vertically,如何在导航时Profile卸载组件vertically,即使在没有导航到组件的情况下也是如此direction='vertical'

javascript react-jsx react-native react-native-router-flux

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

Sublime文本语法着色报价问题

我正在使用崇高的文本3来编写一些反应原生的东西,当在文本组件中编写时,我使用引号来搞乱所有语法着色,如下图所示.有没有什么办法解决这一问题 ?

语法突出显示混乱

sublimetext3 sublime-text-plugin react-native

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

反应原生Android启动画面

我正在尝试为Android RN应用程序构建启动画面.我按照这里描述的步骤操作:https://www.bignerdranch.com/blog/splash-screens-the-right-way/

不幸的是,在尝试启动我的应用程序时,构建成功但应用程序崩溃说:

Error type 3
Error: Activity class {com.needlios/com.needlios.MainActivity} does not exist.
Run Code Online (Sandbox Code Playgroud)

有谁知道这可能来自哪里?

我有以下代码:

SplashScreen.java

package com.needlios;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

package com.needlios;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from …
Run Code Online (Sandbox Code Playgroud)

java android react-native

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

React-native/Enzyme:mount在本机元素上抛出"未知道具"

我正在使用React Native中的Jest和Enzyme编写测试来完全测试我的组件行为和内部函数.浅测试似乎没问题但是当使用mount时它只是抛出

在此输入图像描述

这是我的package.json.

{
  "name": "Despirithium",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "buildandroid": "react-native bundle --platform=android --entry-file=index.android.js --bundle-output='android/app/src/main/assets/index.android.bundle?dev=false",
    "test": "jest --watch"
  },
  "dependencies": {
    "axios": "^0.15.*",
    "dpath": "^2.0.2",
    "evosphere-router": "0.1.9",
    "immutable": "^3.8.1",
    "intl": "^1.2.5",
    "lodash": "^4.16.4",
    "node-uuid": "^1.4.7",
    "normalizr": "^2.2.1",
    "react": "15.3.2",
    "react-native": "0.36.0",
    "react-native-drawer": "^2.3.0",
    "react-native-i18n": "^0.1.1",
    "react-native-image-picker": "^0.22.12",
    "react-native-router-flux": "^3.35.0",
    "react-native-tabs": "^1.0.9",
    "react-redux": "^4.4.5",
    "redux": "^3.6.0",
    "redux-immutable": "^3.0.8",
    "redux-logger": "^2.7.0",
    "redux-thunk": "^2.1.0",
    "string-template": "^1.0.0",
    "tcomb-form-native": "^0.6.1"
  },
  "devDependencies": {
    "babel-core": "^6.14.0",
    "babel-jest": "^17.0.2",
    "babel-plugin-transform-object-rest-spread": …
Run Code Online (Sandbox Code Playgroud)

jsdom reactjs jestjs react-native enzyme

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

IDE中出现VSCode eslint错误,但CLI中没有

我在VScode中具有绝对导入功能,该功能可以很好地构建并且可以在命令行中使用eslint很好地运行,但在VSCode中则不能。

下图是vscode中的错误以及linter的输出。

vscode错误 好吧

我也有以下jsconfig.json文件:

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "baseUrl": "./src",
    "paths": {
      "*": ["*"],
      "components/*": ["components/*"],
      "redux/*": ["redux/*"]
    }
  },
  "include": ["src"]
}
Run Code Online (Sandbox Code Playgroud)

关于如何使VSCode解决导入问题并因此具有Intellisense的任何想法?

javascript reactjs eslint visual-studio-code

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

名称中的React native Image变量不起作用

我正在尝试加载一个在其源代码中有变量的图像,就像这样.

<View>
  {_.map(this.state.ambiences, (id) => {
    var image = require('../../assets/img/ambiances/icons/' + label + '.png'); // variable label equals "chic" here
    var image2 = require('../../assets/img/ambiances/icons/chic.png');
    return <Image style={styles.pastilleOverlay} source={image} />;
  })}
</View>
Run Code Online (Sandbox Code Playgroud)

我收到以下错误(尝试设置变量图像时抛出):需要未知模块"../../assets/img/ambiances/icons/chic.png"

如果我对该var image = ...行进行注释,它source={image2}在Image标签中可以正常工作.

我检查过,两个字符串完全相同.有任何想法吗 ?

image ios react-native

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

URL验证.ng-pattern无效

$scope.regex = '^((http|https|ftp):\/\/)?([a-z]+\.)?[a-z0-9-]+(\.[a-z]{1,4}){1,2}(/.*\?.*)?$';

This is the regular expression i'm using to validate url, and its working fine. I have checked it on AngularJS website.
Run Code Online (Sandbox Code Playgroud)
<div class="field_input">
  <div style="width: 100%;">
    <input type="text" name="website" ng-model="custom.websites" placeholder="www.daiict.ac.in" ng-minlength=3 ng-pattern="regex" required/>
  </div>
</div>
<div class="valid-chk" ng-show="requestForm1.website.$dirty" style="margin-top: 5px;">
  <i style="font-size: 1.15em;padding:0px;" ng-class="{'false':'icon-close', 'true': 'icon-correct'}[requestForm1.website.$valid]" class="icon-correct"></i>
</div>
Run Code Online (Sandbox Code Playgroud)

这是html片段,我试图验证输入字段.但这不起作用.此外,当我使用ng-pattern时,输入字段上的所有其他验证(除了必需)也不起作用.知道为什么......

html regex validation jquery angularjs

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

道具数据在使用 react-native 的 componentDidMount 中不起作用

在过去的 24 小时里,我一直在为这个问题而苦苦挣扎。问题是,我在父类中传递道具并在子组件中调用道具数据。当我检查渲染方法时,数据显示正确,但在调用它componentDidMount时显示为空。

这是我的代码示例

class parent extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      isOpen: false,
      day:'monday',
      data:[],
      data1:[]
    }
  }

  back () {
    this.props.navigator.pop();
  }

  Mon(){
    var record=[];
    this.state.data.map((data) => {
      if(data.frequency[0].day == 'Monday'){
        record.push(data);
      }
    });
    this.setState({data1:record});
  }

  componentWillMount() {
    this.fetchData();
  }

  fetchData() {
  //here i am getting the data from service and set the data to the state
  }

  render(){
    return(
      <View style={styles.Maincontainer}>
        <View style={styles.navbar}>
          <View style={styles.navbarContainer}>
            <View style={styles.navbarIcon}>
              <TouchableOpacity style={styles.button} onPress={() => this.back()}>
                <Image
                  style={styles.menu2} …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native

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

React native alt dispatcher this.dispatch不是Babel 6的函数

我今天早上将我的项目从RN 0.15.0升级到0.16.0,由于传递给Babel 6而出现了很多错误.有一个我不知道的(我猜我的.babelrc文件中缺少了它)

此代码在升级之前工作正常:

'use strict';

import alt from '../alt';
import MeStore from '../stores/Me';

export class MeActions {
 showedCurrentPosition(showed) {
    this.dispatch(showed);
  }
}

export default alt.createActions(MeActions);
Run Code Online (Sandbox Code Playgroud)

这是我使用插件alt的Alt.js文件:

'use strict';

import Alt from 'alt';
export default new Alt();
Run Code Online (Sandbox Code Playgroud)

现在,我在调用时运行代码"this.dispatch不是函数" MeActions.showedCurrentPosition(true);

运行应用程序时抛出错误

javascript babeljs react-native

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

在 Django 多对多关系中添加属性

我有以下 Django 模型:

class Lesson(models.Model):
    title = models.TextField()

class Course(models.Model):
    lessons = models.ManyToManyField(Lesson)

class User(AbstractUser):
    favorites = models.ManyToManyField(Lesson)
Run Code Online (Sandbox Code Playgroud)

我有一条路线 /courses/course_id 返回课程详细信息,包括一系列课程(使用 Django Rest Framework)

我如何根据我的用户收藏夹在课程对象中返回附加属性收藏夹。

我尝试了以下操作:

course = self.get_object(course_id)
favorites = request.user.favorites

for lesson in course.lessons.all():
    if lesson in favorites.all():
        lesson.favorite = True

serializer = CourseDetailSerializer(course, context=serializer_context)
return Response(serializer.data)
Run Code Online (Sandbox Code Playgroud)

但是返回时就不起作用了:

(django.core.exceptions.ImproperlyConfigured:字段名称favorite对于 model 无效Lesson

我的序列化器:

class CourseDetailSerializer(serializers.HyperlinkedModelSerializer):
    lessons = LessonListSerializer(many=True, read_only=True)

    class Meta:
        model = Course
        fields = ('id', 'lessons', 'name', 'title')


class LessonSerializer(serializers.ModelSerializer):
    class Meta:
        model …
Run Code Online (Sandbox Code Playgroud)

python django python-3.x django-rest-framework

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