安装 es6 依赖包

1
2
3
4
npm i --save-dev babel-cli
npm i --save-dev babel-plugin-transform-async-generator-functions
npm i --save-dev babel-plugin-transform-object-rest-spread
npm i --save-dev babel-plugin-transform-runtime babel-preset-latest

自动重启 依赖包

1
npm i --save-dev nodemon

编写 npm scripts

1
2
3
  "scripts": {
    "start": "nodemon ./src/server.js --exec babel-node -e js"
  },

./src/server.js 是你的 es6 代码

执行

1
npm start

完整 package.json 参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "name": "nodejs es6 run",
  "version": "0.1.0",
  "description": "",
  "main": "./src/server.js",
  "scripts": {
    "start": "nodemon ./src/server.js --exec babel-node -e js",
    "h" : "nodemon -h"
  },
  "author": "",
  "devDependencies": {
    "babel-cli": "^6.24.0",
    "babel-plugin-transform-async-generator-functions": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.23.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-latest": "^6.23.0",
    "nodemon": "^1.11.0"
  },
  "dependencies": {
    "body-parser": "^1.17.1",
    "express": "^4.15.2",
    "lodash": "^4.17.4"
  }
}

Read More

weex安装配置运行

参考网站

https://weex.apache.org/cn/ https://weex.apache.org/cn/references/index.html https://github.com/weexteam/weex-pack

基础环境

1
2
brew install node
npm install -g weex-toolkit

运行web

1
npm start

http://localhost:8080/index.html

weexpack

1
npm install -g weexpack

运行ios

1
weex platform add ios

集成devtools

Read More

编译发布安装

1. 准备证书请求文件
1
certSigningRequest

  • 钥匙串管理 => 证书助理 => 从证书颁发机构请求证书…

  • 证书信息

    • 输入 电子邮件
    • 输入 常用名称(可以是苹果的账号名字)
    • 选择存储到磁盘

2. 登录开发者账号

https://developer.apple.com/account

3. 创建证书
1
iOS Certificates

https://developer.apple.com/account/ios/certificate/

  • 推荐分别创建 开发证书 & 发布证书

4. 创建引用 ID
1
iOS App IDs

https://developer.apple.com/account/ios/identifier/bundle

ID规则 com.myco.app 和域名很像,倒着写

5. 登记你的设备
1
UDID

https://developer.apple.com/account/ios/device/

可以通过 itunes => 我的设备 => 摘要 => udid(通过右键切换)

6. 创建部署配置
1
iOS Provisioning Profiles

https://developer.apple.com/account/ios/profile/

  • 推荐分别创建 开发 & 发布 部署文件

7. xcode 下载配置文件

xcode => Preferences => Accounts => 添加 Apple IDS => Download All Profiles(全部下载) 或者 Manage Certificates(单独下载)

8. xcode 设置签名

Targets => General => Signing

默认是自动的,如果编译出错,请选择手动配置

9. xcode 设置发布选项

Product => Scheme => Edit Scheme => Run => Build Configuration => Release

10. xcode 编译发布文件

Product => Archive

11. xcode 发布adHoc 本地最后测试

Windows => Organizer => iOS Apps => Export

12. xcode 发布到 app store

Windows => Organizer => iOS Apps => Upload to App Store

Read More

APK编译发布安装

1. 生成key

1
2
3
mdidr /keystores/apk
cd /keystores/apk
keytool -genkey -v -keystore my-release-key.keystore -alias jpfigure-key-alias -keyalg RSA -keysize 2048 -validity 10000

2. 修改
1
/android/app/build.gradle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// key store
MYAPP_RELEASE_STORE_FILE    =   "../../keystores/apk/my-release-key.keystore"
MYAPP_RELEASE_KEY_ALIAS     =   "jpfigure-key-alias"
MYAPP_RELEASE_STORE_PASSWORD=   "0p9o8i7u"
MYAPP_RELEASE_KEY_PASSWORD  =   "0p9o8i7u"

android {

    defaultConfig {
    }
    signingConfigs {
        release {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

3. 编译

cd android && ./gradlew assembleRelease

4. 编译并安装到手机

cd android && ./gradlew installRelease

  • 错误信息
1
Could not list contents of '/Users/lise/WorkSpace/idlebox/node_modules/react-native/third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link.
  • 方案, unlink
1
unlink node_modules/react-native/third-party/glog-0.3.4/test-driver

Read More

前言

国内安装国外源,容易失败,如

1
node-sass
。因为 GitHub Releases 里的文件都托管在 s3.amazonaws.com上面,而这个网址在国内总是网络不稳定,所以我们需要通过第三方服务器下载这个文件。

方案

方法一:使用淘宝源 npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ npm config set phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/ npm config set electron_mirror=https://npm.taobao.org/mirrors/electron/ npm config set registry=https://registry.npm.taobao.org

这样使用 npm install 安装 node-sass、electron 和 phantomjs 时都能自动从淘宝源上下载。

方法二:安装cnpm »> 也是淘宝源的做法 npm install -g cnpm cnpm install
这样也可以成功安装node-saa

Read More

组件

官方组件 CameraRoll

安装

  • RCTCameraRoll 库。进入到工程项目中的 node_module/react-native/Libraries/CameraRoll
  • 把 RCTCameraRoll.xcodeproj 添加到在项目工程的 Liberaries 文件夹下
  • 在 Build Phases -> Link Binary With Libraries 里添加 libRCTCameraRoll.a
  • 由于苹果安全策略更新,还需要在 Info.plist 配置请求照片相的关描述字段(Privacy - Photo Library Usage Description)

代码

1
2
3
4
5
6
7
8
9
    //保存图片
    saveImg(img) {
      var promise = CameraRoll.saveToCameraRoll(img);
      promise.then(function(result) {
        alert('保存成功!地址如下:\n' + result);
      }).catch(function(error) {
        alert('保存失败!\n' + error);
      });
    }

Read More