VUE uses external JS and call native API operation example

This example describes the VUE uses external JS and call native API operations. Share to everyone for reference, specifically:

Vue uses external JS

We will JSs that often need to be used so that we need to introduce external JS and then use.

Implementation Method

We need to use the SHA256 to encrypt the user’s password during development.

We have a little transformation of JS.

Function SHA256_Digest (Data) {Sha256_init (); SHA256_UPDATE (DATA, DATA.LENGTH); SHA256_Final (); Return Sha256_Encode_HEX ();} export {sha256_digest}
  As with this code, we need to add a line of code to export this JS method.  
Export {sha256_digest}

We introduced JS when used.

  Import {sha256_digest} from "@ / assets / sha256.js"  
We can import one or more methods, here imported a method .
This is used in the code

 SHA256_Digest (this.user.passwOrd   
Call native API

summary

We are developing mobile phones The program is time, we often need to use the camera and QR code. Digital paradise offers a lot of native API support.
 http://www.html5plus.org/doc/   
1. Select the module you need to use in HBuilder

2. Call the corresponding API interface in the component code.

Takephoto () {var _self = this; var CMR = plus.camera.getcamera (); var fmt = CMR.SupportedImageFormats [0]; cmr.captureImage (Function (PATH) {Plus.io.resolvelocalFileSystemurl (path, function (entry) {var push = []; fileary.push = []; fileary.push (tmpath); _self. CompressImg (Fileary);} (c) {}, {Format: FMT};}

PLUS is the interface call of H5 +.

Precautions

When we use these interfaces, we need to pack the system into app, otherwise Plus cannot be used.

It is hoped that this article is designed to help everyone Vue.js program. vue 使用外部JS与调用原生API操作示例

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment