我想嵌套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'
?
我正在尝试为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) 我正在使用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) 我在VScode中具有绝对导入功能,该功能可以很好地构建并且可以在命令行中使用eslint很好地运行,但在VSCode中则不能。
下图是vscode中的错误以及linter的输出。
我也有以下jsconfig.json
文件:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"baseUrl": "./src",
"paths": {
"*": ["*"],
"components/*": ["components/*"],
"redux/*": ["redux/*"]
}
},
"include": ["src"]
}
Run Code Online (Sandbox Code Playgroud)
关于如何使VSCode解决导入问题并因此具有Intellisense的任何想法?
我正在尝试加载一个在其源代码中有变量的图像,就像这样.
<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标签中可以正常工作.
我检查过,两个字符串完全相同.有任何想法吗 ?
$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时,输入字段上的所有其他验证(除了必需)也不起作用.知道为什么......
在过去的 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) 我今天早上将我的项目从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);
我有以下 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) react-native ×7
javascript ×3
reactjs ×3
android ×1
angularjs ×1
babeljs ×1
django ×1
enzyme ×1
eslint ×1
html ×1
image ×1
ios ×1
java ×1
jestjs ×1
jquery ×1
jsdom ×1
python ×1
python-3.x ×1
react-jsx ×1
regex ×1
sublimetext3 ×1
validation ×1