小编Aru*_*mar的帖子

是否有必要在Windows上为“ react-native init AwesomeProject”安装Python以用于react-native?

我正在尝试在Windows7上设置react-native。

我安装了以下东西:

C:\Windows\system32>node -v
v6.2.0    
C:\Windows\system32>npm -v
3.8.9    
C:\Windows\system32>javac -version
javac 1.8.0_60
Run Code Online (Sandbox Code Playgroud)

我尚未安装Python。当我尝试react-native init AwesomeProject在AwesomeProject中仅下载2件事时:node_modules dir和

package.json

{
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "react-native": "0.41.2"
  }
}
Run Code Online (Sandbox Code Playgroud)

这是不完整的项目。ReactNative0.41文件说

我们建议安装Node.js和Python2

为什么建议将Python与react-native一起使用?react-native是否需要python克隆种子项目?

我还安装了以下内容:

  • Android SDK
  • Android SDK平台
  • Android虚拟设备
  • Android 6.0 SDK工具
  • Google API
  • Intel x86 Atom系统映像
  • 英特尔x86 Atom_64系统映像
  • Google API Intel x86 Atom_64系统映像

python react-native-android

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

Typescript 方法使用方法装饰器返回未定义

如果这是一个愚蠢的问题,我深表歉意。我是打字稿新手,正在学习打字稿装饰器。我找到了一个代码:MethodDecorator 来记录参数和结果。

日志装饰器

function log (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
    let originalMethod = descriptor.value;
    descriptor.value = function (...args:any[]) {
        //before
        console.log(`${key} method called with args: ${JSON.stringify(args)}`);

        let result = originalMethod.apply(this, args);

        //after
        console.log(`${key} method return value: ${JSON.stringify(result)}`);
    }
    return descriptor;
}
Run Code Online (Sandbox Code Playgroud)

我在 Book 类中使用 @log 和 setId 和 getId 方法

书.ts

class Book{
    constructor(public id: number, public title: string, public publisher: string){}

    @log
    setId(id: number){
        this.id = id;
    }
    @log
    getId(): number{
        return this.id;
    }
}
Run Code Online (Sandbox Code Playgroud)

所有代码都工作正常,但当我运行此代码时 getId …

javascript typescript1.8

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