我正在尝试在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克隆种子项目?
我还安装了以下内容:
如果这是一个愚蠢的问题,我深表歉意。我是打字稿新手,正在学习打字稿装饰器。我找到了一个代码: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 …