在HbuilderX的Uni-app中引入crypto-js md5


在 hbuilderX的菜單“視圖”中選擇“顯示終端”,在終端中把當前目錄定位到uni-app的根目錄,這樣才可以把crypto-js庫安裝在正確的位置,在終端中鍵入:npm install crypto-js ,等待片刻,crypto-js 庫就裝在了uni-app的根目錄的:/node_modules/crypto-js/* 中了。要使用其相關加解密算法,只要在代碼中引入:import cj from '../../../node_modules/crypto-js/crypto-js.js' 就可以搞事情了。

比如:

<script>

import cj from '../../../node_modules/crypto-js/crypto-js.js'

                const data = {

t:"sign up",

                    account: this.account,

                    password: cj.MD5(this.password).toString(),

                    email: email0,

cellphone:cellphone0,

                }

</script>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM