小编KT *_*rks的帖子

反应原生圆变换翻译动画

嗨,我希望animated.view像圆圈一样移动.我用窦思考这个但是它不起作用.有人知道怎么做吗?我不想旋转视图.它应该在圆圈中移动.我是新来的本地人.如果有人可以帮助我会很好.

在此输入图像描述

//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Animated, Button, TouchableOpacity } from 'react-native';

// create a component
class MyClass extends Component {
  constructor() {
    super()
    this.animated = new Animated.Value(0);
  }

  animate() {    
    this.animated.setValue(0)
    Animated.timing(this.animated, {
      toValue: Math.PI *2,
      duration: 1000,
    }).start();
  }


  render() {
    const translateY = this.animated.interpolate({
      inputRange: [0, Math.PI *2],
      outputRange: [0, 200]
    });
    const translateX = translateY
    const transform = [{ translateY }, {translateX}];
    return (
      <View style={styles.container}>
        <Animated.View …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-animated

7
推荐指数
2
解决办法
4529
查看次数

启动看守员时出错

嗨,当我想用​​'react-native start'启动我的应用程序时,我收到此错误.有人知道该怎么办?我试图将watchman文件夹和项目文件夹的权限更改为chmod -R 777'path'

Metro Bundler ready.

Loading dependency graph...watchman warning:  opendir(/home/t/react/testApp/android/app/build/generated/source/r/debug/com) -> Permission denied. Marking this portion of the tree deleted
Recrawled this watch 1 times, most recently because:
/home/t/react/testApp: dir missing from internal state
To resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del /home/t/react/testApp ; watchman watch-project /home/t/react/testApp`

opendir(/home/t/react/testApp/android/app/build/generated/source/r/debug/com) -> Permission denied. Marking this portion of the tree deleted
Recrawled this watch 1 times, most recently because:
/home/t/react/testApp: dir missing from internal …
Run Code Online (Sandbox Code Playgroud)

javascript npm watchman react-native

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

使用es6模块和webpack导入momentjs无法分配给只读属性

我做了以下步骤

npm install moment --save
import moment from "moment"
Run Code Online (Sandbox Code Playgroud)

当我想导入momentjs时,我收到以下错误:

Uncaught TypeError: Cannot assign to read only property 'clone' of object '#<Moment>' (moment.js:3837 )
Run Code Online (Sandbox Code Playgroud)

时刻版:^ 2.22.1

我使用webpack 4.

尝试像这样导入也失败了同样的错误:

import moment from "moment/src/moment"
Run Code Online (Sandbox Code Playgroud)

有人能帮助我吗?我真的不知道如何解决这个问题.我的Webpack配置:

const path = require('path')
const BrowserSyncPlugin = require("browser-sync-webpack-plugin")
var webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = {
  entry: './src/js/index.js',
  output: {
    path: path.resolve(__dirname, 'static'),
    filename: 'monitor-bundle.js'

  },
  devtool: 'source-map',
  mode: 'development',

  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader" …
Run Code Online (Sandbox Code Playgroud)

javascript momentjs ecmascript-6 webpack webpack-4

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

将多个视图的原生动画作为圆圈进行反应

我想要2个视图,它们像一个圆圈一样变换,同时没有旋转.第一个视图从顶部开始,第二个视图从底部开始.我已经问过如何用一个视图做到这一点.我不认为它运行两个视图. 之前的问题

在此输入图像描述

//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Animated, Button, TouchableOpacity } from 'react-native';

// create a component
export default class App extends Component {
  constructor() {
      super()
      this.animated = new Animated.Value(0);
      this.animated2 = new Animated.Value(0);

      var range = 1, snapshot = 50, radius = 100;
      /// translateX
      var inputRange = []
      var outputRange = [] 
      var outputRange2 = []
      for (var i=0; i<=snapshot; ++i) {
          var value = i/snapshot;
          var move …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-animated

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

反应调试模式和普通模式之间的本机不同行为

嗨,我有一个非常复杂的问题。所以我在github上为这个问题创建了一个新的仓库。因此,您可以克隆它并查看问题所在。

https://github.com/guitar9/hafas-client-example

我在这个项目中使用https://github.com/public-transport/hafas-client来获取火车站和火车站的信息。

client.journeys(münchenHbf, münchenPassing)
.then((response)=>{
  console.log('===============response=====================');
  console.log(response);
  console.log('====================================');
})
.catch(console.error)
Run Code Online (Sandbox Code Playgroud)

请求在

node_modules/hafas-client/lib/request
Run Code Online (Sandbox Code Playgroud)

问题是在调试模式下一切正常(摇动电话并启动远程JS调试),但是当我停止JS调试时,出现错误“ PARSE”。

所以我在request.js中查找并以调试模式而不是调试模式注销了请求和响应。

请求调试模式

{
    "method": "post",
    "body": "{\"lang\":\"en\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"TripSearch\",\"req\":{\"outDate\":\"20180614\",\"outTime\":\"174837\",\"ctxScr\":null,\"getPasslist\":false,\"maxChg\":5,\"minChgTime\":0,\"depLocL\":[{\"lid\":\"A=1@L=008000261@\"}],\"viaLocL\":null,\"arrLocL\":[{\"lid\":\"A=1@L=008004158@\"}],\"jnyFltrL\":[{\"type\":\"PROD\",\"mode\":\"INC\",\"value\":\"1023\"},{\"type\":\"META\",\"mode\":\"INC\",\"meta\":\"notBarrierfree\"}],\"getTariff\":false,\"outFrwd\":true,\"getPT\":true,\"getIV\":false,\"getPolyline\":false,\"numF\":5,\"trfReq\":{\"jnyCl\":2,\"tvlrProf\":[{\"type\":\"E\",\"redtnCard\":null}],\"cType\":\"PK\"}}}],\"client\":{\"id\":\"DB\",\"v\":\"16040000\",\"type\":\"IPH\",\"name\":\"DB Navigator\"},\"ext\":\"DB.R15.12.a\",\"ver\":\"1.16\",\"auth\":{\"type\":\"AID\",\"aid\":\"n91dB8Z77MLdoR0K\"}}",
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "user-agent": "https://github.com/public-transport/hafas-client"
    },
    "query": {
        "checksum": "6af3b74db20e14c7f94012e3de55dce6"
    }
}
Run Code Online (Sandbox Code Playgroud)

响应调试模式

所有信息。一切都好。

请求未处于调试模式

{
    "method": "post",
    "body": "{\"lang\":\"en\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"TripSearch\",\"req\":{\"outDate\":\"Invalid DateTime\",\"outTime\":\"Invalid DateTime\",\"ctxScr\":null,\"getPasslist\":false,\"maxChg\":5,\"minChgTime\":0,\"depLocL\":[{\"lid\":\"A=1@L=008000261@\"}],\"viaLocL\":null,\"arrLocL\":[{\"lid\":\"A=1@L=008004158@\"}],\"jnyFltrL\":[{\"type\":\"PROD\",\"mode\":\"INC\",\"value\":\"1023\"},{\"type\":\"META\",\"mode\":\"INC\",\"meta\":\"notBarrierfree\"}],\"getTariff\":false,\"outFrwd\":true,\"getPT\":true,\"getIV\":false,\"getPolyline\":false,\"numF\":5,\"trfReq\":{\"jnyCl\":2,\"tvlrProf\":[{\"type\":\"E\",\"redtnCard\":null}],\"cType\":\"PK\"}}}],\"client\":{\"id\":\"DB\",\"v\":\"16040000\",\"type\":\"IPH\",\"name\":\"DB Navigator\"},\"ext\":\"DB.R15.12.a\",\"ver\":\"1.16\",\"auth\":{\"type\":\"AID\",\"aid\":\"n91dB8Z77MLdoR0K\"}}",
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "user-agent": "https://github.com/public-transport/hafas-client"
    },
    "query": {
        "checksum": "0d8186da7b06f9cc094075a2a6e21b00"
    }
}
Run Code Online (Sandbox Code Playgroud)

响应不在调试模式下

{
    "ver": "1.16",
    "ext": "DB.R15.12.a",
    "lang": "eng",
    "id": "",
    "err": "PARSE",
    "svcResL": [] …
Run Code Online (Sandbox Code Playgroud)

javascript android request reactjs react-native

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

反应本地TypeError:尝试分配给只读属性

嗨,我是新来的反应本地人。启动应用程序时出现此错误:

"TypeError: Attempted to assign to readonly property.
This error is located at:
    in MyClass (at renderApplication.js:35)
    in RCTView (at View.js:112)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:112)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:34)
stopTracking
    AnimatedValue.js:279:9
start
    AnimatedImplementation.js:188:4"
Run Code Online (Sandbox Code Playgroud)

在此代码上。有人可以帮我吗?我找不到此代码有什么问题。我试图重新启动npm react native服务器,但仍无法正常工作。该应用程序只能将文本从一个位置转换到另一位置。

//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Animated } from 'react-native';

// create a component
class MyClass extends Component {
  constructor(){
    super()
    this.animated = new Animated.Value(0);
  }
  componentDidMount() { …
Run Code Online (Sandbox Code Playgroud)

javascript android ios reactjs react-native

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