内容简介:Linking is not needed anymore.
rn-qr-generator
Getting started
$ npm install rn-qr-generator --save
Mostly automatic installation
$ react-native link rn-qr-generator
Important:
Linking is not needed anymore. react-native@0.60.0+
supports dependencies auto linking.
For iOS you also need additional step to install auto linked Pods (Cocoapods should be installed):
cd ios && pod install && cd ../
Manual installation
iOS
-
In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] -
Go to
node_modules➜rn-qr-generatorand addRNQrGenerator.xcodeproj -
In XCode, in the project navigator, select your project. Add
libRNQrGenerator.ato your project'sBuild Phases➜Link Binary With Libraries -
Run your project (
Cmd+R)<
Android
-
Open up
android/app/src/main/java/[...]/MainActivity.java
-
Add
import com.gevorg.reactlibrary.RNQrGeneratorPackage;to the imports at the top of the file -
Add
new RNQrGeneratorPackage()to the list returned by thegetPackages()method
-
Append the following lines to
android/settings.gradle:include ':rn-qr-generator' project(':rn-qr-generator').projectDir = new File(rootProject.projectDir, '../node_modules/rn-qr-generator/android') -
Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':rn-qr-generator')
Usage
import RNQRGenerator from 'rn-qr-generator';
RNQRGenerator.generate({
value: 'https://github.com/gevorg94/rn-qr-generator', // required
height: 100,
width: 100,
base64: false, // default 'false'
backgroundColor: 'black', // default 'white'
color: 'white', // default 'black'
})
.then(response => {
const { uri, width, height, base64 } = response;
this.setState({ imageUri: uri });
})
.catch(error => console.log('Cannot create QR code', error));
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
微信小程序(开发入门及案例详解)
李骏、边思 / 机械工业出版社 / 2017-3-1 / 59.0
本书可分为3部分,第一部分作为基础章节,介绍了第一个小程序的搭建流程,让大家能快速上手;同时对小程序框架原理进行了详细介绍,为后面学习组件、API打下基础。 第二部分对小程序组件、API进行介绍,对组件、API的使用、注意事项进行详细讲解,并给出示例代码。 最后一部分精选5个由浅入深的案例,对小程序研发进行实战讲解,涵盖了实际项目中可能涉及的技术方案和使用方法,具备很强的实战意义。 ......一起来看看 《微信小程序(开发入门及案例详解)》 这本书的介绍吧!