ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    Flutter 生成指定的位置的0

    Aug 24, 20228 min read
      double genDigits(double d) {
        var i = d.round();
        var length = i.toString().length;
        final fixedLengthList =
            List<int>.generate(length-2, (int index) => 0, growable: false);
        var tmpNum = double.parse("1${fixedLengthList.join("")}");
        return tmpNum;
      }
    
    void main() {
      print(genDigits(112));  // 10
    }
    
    

    相关文章

    在JS 中哪些 api 会修改原数组的值?

    JavaScript中的API如`push()`, `pop()`, `shift()`, `unshift()`, `splice()`, `sort()`, `reverse()`, `fill()`, `copyWithin()`等可以直接修改原数组,使用时需谨慎。

    在 Swift 中,unowned 和 weak 是什么? 解决了什么问题? 它们的区别是什么? 相关的代码演示和对比

    Swift 中的 unowned 和 weak 用于解决循环引用问题,其中 unowned 要求属性非 nil 且不会自动置为 nil,而 weak 属性可以为 nil 且在对象释放时自动置为 nil。

    Chrome 插件开发 chrome.storage.local.get 异步改造

    Chrome插件开发中,通过异步函数`readLocalStorage`获取本地存储数据,并在`getData`函数中使用该方法更新网页元素内容。

    Gorm中 使用分页的代码案例

    在Gorm中,通过使用`Limit`和`Offset`函数,可以轻松实现分页查询,如示例代码所示,通过指定偏移量和记录数来获取特定页的用户数据。

    go net/http 库支持 cookies吗?

    net/http库支持通过SetCookie和CookieJar等函数和结构体来设置和管理HTTP请求和响应中的cookies。