current position:Home>ethers. JS could not detect network (event ='nonetwork ') appears on the real machine debugging of uniapp

ethers. JS could not detect network (event ='nonetwork ') appears on the real machine debugging of uniapp

2022-02-03 23:16:35 Q & A of Denglian community

import {        mapState    } from 'vuex';    import {uniIcons} from '@dcloudio/uni-ui'    import { ethers } from 'ethers'    export default {        components: {uniIcons},        data() {            return {                provider: null,                balance: '0.0000000',            };        },        onLoad(){            this.provider = new ethers.providers.JsonRpcProvider('https://ropsten.infura.io/v3/58514c44f8ee4bf1a194591ef047b***');            console.log(this.provider)            this.getBalance()        },        computed:{            ...mapState(['hasLogin'])        },        methods: {            getBalance(){                let address = "0xEf40248793A14eD0d5B6Bc493bB559f5168cac91";                this.provider.getBalance(address).then((balance) => {                    //  The balance is  BigNumber (in wei);  Formatted as  ether  character string                     this.balance = ethers.utils.formatEther(balance);                });            }        }    }

image.png Real machine (iPhone6) The above problems appear in debugging , When you get the balance . stay HBuilderX Editor above H5 The version is normal , The balance can be displayed :image.png






Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032316331766.html

Random recommended