Flutter 初识:导航控件

news2024/9/25 23:13:33

Flutter导航控件小结

    • 路由与导航
      • Navigator
        • 核心方法
        • 属性
        • 示例
          • 基本导航示例
          • 替换当前页面并推入新页面
          • 使用命名路由
          • 动态生成路由
          • 额外的导航功能
        • 完整示例代码
      • MaterialPageRoute
        • 属性
        • 示例
      • CupertinoPageRoute
        • 属性
        • 示例
    • 应用栏与底部导航
      • AppBar
        • 属性解析
        • 示例
      • BottomNavigationBar
        • 属性解析
        • 示例
      • Drawer
        • 属性解析
        • 示例
    • 示例

路由与导航

Navigator

Navigator 用于管理应用程序的路由,通过堆栈结构来实现页面的进出。它支持页面的推入(push)和弹出(pop)操作,允许在应用中进行复杂的导航模式。

核心方法
  • Navigator.push: 将新页面推入导航堆栈。
  • Navigator.pop: 从导航堆栈中弹出当前页面。
  • Navigator.pushReplacement: 替换当前页面,并将新页面推入导航堆栈。
  • Navigator.pushNamed: 使用命名路由推入新页面。
  • Navigator.popUntil: 弹出导航堆栈中的页面直到满足特定条件。
  • Navigator.pushAndRemoveUntil: 推入新页面并移除所有先前的页面,直到满足特定条件。
  • Navigator.maybePop: 尝试从导航堆栈中弹出当前页面,如果没有更多页面可以弹出,则返回false。
属性
  • initialRoute: 应用启动时的初始路由。
  • onGenerateRoute: 动态生成路由的回调函数。
  • onUnknownRoute: 当无法找到匹配路由时调用的回调函数。
示例
基本导航示例
Navigator.push(
  context,
  MaterialPageRoute(builder: (context) => SecondPage()),
);

Navigator.pop(context);
替换当前页面并推入新页面
Navigator.pushReplacement(
  context,
  MaterialPageRoute(builder: (context) => SecondPage()),
);
使用命名路由

定义命名路由:

void main() {
  runApp(MaterialApp(
    initialRoute: '/',
    routes: {
      '/': (context) => FirstPage(),
      '/second': (context) => SecondPage(),
    },
  ));
}

使用命名路由导航:

Navigator.pushNamed(context, '/second');
动态生成路由
void main() {
  runApp(MaterialApp(
    onGenerateRoute: (settings) {
      if (settings.name == '/second') {
        return MaterialPageRoute(
          builder: (context) => SecondPage(),
        );
      }
      // Define other routes here
      assert(false, 'Need to implement ${settings.name}');
      return null;
    },
  ));
}
额外的导航功能

推入新页面并移除所有先前的页面,直到满足特定条件

Navigator.pushAndRemoveUntil(
  context,
  MaterialPageRoute(builder: (context) => SecondPage()),
  ModalRoute.withName('/'),
);

尝试从导航堆栈中弹出当前页面

bool popped = await Navigator.maybePop(context);
if (!popped) {
  // Handle the case where there are no more pages to pop
}
完整示例代码
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      initialRoute: '/',
      routes: {
        '/': (context) => FirstPage(),
        '/second': (context) => SecondPage(),
        '/third': (context) => ThirdPage(),
      },
    );
  }
}

class FirstPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("First Page")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => SecondPage()),
                );
              },
              child: Text('Push to Second Page'),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.pushReplacement(
                  context,
                  MaterialPageRoute(builder: (context) => SecondPage()),
                );
              },
              child: Text('PushReplace to Second Page'),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/third');
              },
              child: Text('Go to Third Page with Named Route'),
            ),
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Second Page")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Navigator.pop(context, 'Data from Second Page');
              },
              child: Text('Pop and Return Data'),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.popUntil(context, ModalRoute.withName('/'));
              },
              child: Text('Pop Until First Page'),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.pushAndRemoveUntil(
                  context,
                  MaterialPageRoute(builder: (context) => ThirdPage()),
                  ModalRoute.withName('/'),
                );
              },
              child: Text('Push and Remove Until First Page'),
            ),
          ],
        ),
      ),
    );
  }
}

class ThirdPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Third Page")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Navigator.pop(context);
              },
              child: Text('Back to Previous Page'),
            ),
            ElevatedButton(
              onPressed: () async {
                bool popped = await Navigator.maybePop(context);
                if (!popped) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text('No more pages to pop')),
                  );
                }
              },
              child: Text('Maybe Pop'),
            ),
          ],
        ),
      ),
    );
  }
}

 
 

MaterialPageRoute

MaterialPageRoute 是一个材料设计风格的页面路由,用于在安卓平台上提供一致的导航体验。它继承自PageRoute,并且实现了TransitionRoute用于处理页面切换时的过渡动画。

属性
  • builder: 构建路由页面的回调函数。
  • settings: 路由的配置信息,如名称、参数等。
  • maintainState: 是否在页面离开视图但未完全移除时保持状态。
  • fullscreenDialog: 是否将页面展示为全屏对话框。
示例
Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => SecondPage(),
    settings: RouteSettings(name: '/second'),
  ),
);

在SecondPage中接收传递的参数:

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final RouteSettings settings = ModalRoute.of(context)!.settings;
    final String? data = settings.arguments as String?;

    return Scaffold(
      appBar: AppBar(title: Text("Second Page")),
      body: Center(child: Text(data ?? 'No data')),
    );
  }
}

 
 

CupertinoPageRoute

CupertinoPageRoute 是一个iOS风格的页面路由,用于在iOS平台上提供一致的导航体验。它同样继承自PageRoute,并实现了TransitionRoute用于处理页面切换时的过渡动画。

属性
  • builder: 构建路由页面的回调函数。
  • settings: 路由的配置信息,如名称、参数等。
  • maintainState: 是否在页面离开视图但未完全移除时保持状态。
  • fullscreenDialog: 是否将页面展示为全屏对话框。
示例
Navigator.push(
  context,
  CupertinoPageRoute(
    builder: (context) => SecondPage(),
    settings: RouteSettings(name: '/second'),
  ),
);

在SecondPage中接收传递的参数:

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final RouteSettings settings = ModalRoute.of(context)!.settings;
    final String? data = settings.arguments as String?;

    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: Text("Second Page"),
      ),
      child: Center(child: Text(data ?? 'No data')),
    );
  }
}

 
 

应用栏与底部导航

AppBar

AppBar 是顶部应用栏,通常用于显示标题、导航按钮等。

属性解析
AppBar({
    super.key,
    this.leading,
    this.automaticallyImplyLeading = true,
    this.title,
    this.actions,
    this.flexibleSpace,
    this.bottom,
    this.elevation,
    this.scrolledUnderElevation,
    this.notificationPredicate = defaultScrollNotificationPredicate,
    this.shadowColor,
    this.surfaceTintColor,
    this.shape,
    this.backgroundColor,
    this.foregroundColor,
    this.iconTheme,
    this.actionsIconTheme,
    this.primary = true,
    this.centerTitle,
    this.excludeHeaderSemantics = false,
    this.titleSpacing,
    this.toolbarOpacity = 1.0,
    this.bottomOpacity = 1.0,
    this.toolbarHeight,
    this.leadingWidth,
    this.toolbarTextStyle,
    this.titleTextStyle,
    this.systemOverlayStyle,
    this.forceMaterialTransparency = false,
    this.clipBehavior,
  })
  • key:用于标识控件的唯一值。
  • leading:可选参数,类型为 Widget,表示前导控件,通常是导航图标。
  • automaticallyImplyLeading:可选参数,类型为 bool,默认为 true,是否自动根据路由生成前导控件。
  • title:可选参数,类型为 Widget,表示标题控件。
  • actions:可选参数,类型为 List,表示操作控件列表,通常是一些图标按钮。
  • flexibleSpace:可选参数,类型为 Widget,表示灵活空间控件。
  • bottom:可选参数,类型为 PreferredSizeWidget,表示底部控件,通常是 TabBar。
  • elevation:可选参数,类型为 double,表示阴影高度。
  • scrolledUnderElevation:可选参数,类型为 double,表示滑动时的阴影高度。
  • notificationPredicate:可选参数,类型为 ScrollNotificationPredicate,表示通知谓词。
  • shadowColor:可选参数,类型为 Color,表示阴影颜色。
  • surfaceTintColor:可选参数,类型为 Color,表示表面颜色。
  • shape:可选参数,类型为 ShapeBorder,表示形状。
  • backgroundColor:可选参数,类型为 Color,表示背景颜色。
  • foregroundColor:可选参数,类型为 Color,表示前景颜色。
  • iconTheme:可选参数,类型为 IconThemeData,表示图标主题。
  • actionsIconTheme:可选参数,类型为 IconThemeData,表示操作图标主题。
  • primary:可选参数,类型为 bool,默认为 true,表示是否为主 AppBar。
  • centerTitle:可选参数,类型为 bool,表示标题是否居中。
  • excludeHeaderSemantics:可选参数,类型为 bool,表示是否排除头部语义。
  • titleSpacing:可选参数,类型为 double,表示标题间距。
  • toolbarOpacity:可选参数,类型为 double,表示工具栏不透明度,默认为 1.0。
  • bottomOpacity:可选参数,类型为 double,表示底部控件不透明度,默认为 1.0。
  • toolbarHeight:可选参数,类型为 double,表示工具栏高度。
  • leadingWidth:可选参数,类型为 double,表示前导控件宽度。
  • toolbarTextStyle:可选参数,类型为 TextStyle,表示工具栏文字样式。
  • titleTextStyle:可选参数,类型为 TextStyle,表示标题文字样式。
  • systemOverlayStyle:可选参数,类型为 SystemUiOverlayStyle,表示系统覆盖层样式。
  • forceMaterialTransparency:可选参数,类型为 bool,表示是否强制材料透明度。
  • clipBehavior:可选参数,类型为 Clip,表示剪切行为。
示例
class ExamplePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.menu),
            onPressed: () {
              // handle menu button press
            },
          ),
          title: Text('AppBar Example'),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.search),
              onPressed: () {
                // handle search button press
              },
            ),
            IconButton(
              icon: Icon(Icons.more_vert),
              onPressed: () {
                // handle more button press
              },
            ),
          ],
          flexibleSpace: Container(
            decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: [Colors.blue, Colors.purple],
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
              ),
            ),
          ),
          bottom: PreferredSize(
            preferredSize: Size.fromHeight(50.0),
            child: Container(
              color: Colors.orange,
              height: 50.0,
              child: Center(child: Text('Bottom Widget')),
            ),
          ),
          elevation: 4.0,
          backgroundColor: Colors.red,
          foregroundColor: Colors.white,
          centerTitle: true,
        ),
        body: Center(child: Text('Hello, world!')),
      ),
    );
  }
}

在这里插入图片描述
 
 

BottomNavigationBar

BottomNavigationBar 是底部导航栏,用于在底部展示多个导航项。

属性解析
BottomNavigationBar({
  super.key,
  required this.items,                   // 必需参数,导航栏项列表
  this.onTap,                            // 点击事件回调
  this.currentIndex = 0,                 // 当前选中的索引
  this.elevation,                        // 阴影高度
  this.type,                             // 导航栏类型
  Color? fixedColor,                     // 固定颜色(已废弃,请使用 selectedItemColor)
  this.backgroundColor,                  // 背景颜色
  this.iconSize = 24.0,                  // 图标大小
  Color? selectedItemColor,              // 选中项颜色
  this.unselectedItemColor,              // 未选中项颜色
  this.selectedIconTheme,                // 选中图标主题
  this.unselectedIconTheme,              // 未选中图标主题
  this.selectedFontSize = 14.0,          // 选中标签字体大小
  this.unselectedFontSize = 12.0,        // 未选中标签字体大小
  this.selectedLabelStyle,               // 选中标签样式
  this.unselectedLabelStyle,             // 未选中标签样式
  this.showSelectedLabels,               // 是否显示选中标签
  this.showUnselectedLabels,             // 是否显示未选中标签
  this.mouseCursor,                      // 鼠标指针样式
  this.enableFeedback,                   // 是否启用反馈
  this.landscapeLayout,                  // 横向布局
  this.useLegacyColorScheme = true,      // 是否使用旧颜色方案
});
  • key:用于标识控件的唯一值。
  • items:必需参数,类型为 List,表示导航栏项列表。
  • onTap:可选参数,类型为 ValueChanged?,点击事件回调,当导航栏项被点击时调用。
  • currentIndex:可选参数,类型为 int,默认为 0,表示当前选中的索引。
  • elevation:可选参数,类型为 double?,表示阴影高度。
  • type:可选参数,类型为 BottomNavigationBarType?,表示导航栏类型,可以是 fixed 或 shifting。
  • backgroundColor:可选参数,类型为 Color?,表示背景颜色。
  • iconSize:可选参数,类型为 double,表示图标大小,默认为 24.0。
  • selectedItemColor:可选参数,类型为 Color?,表示选中项颜色。
  • unselectedItemColor:可选参数,类型为 Color?,表示未选中项颜色。
  • selectedIconTheme:可选参数,类型为 IconThemeData?,表示选中图标主题。
  • unselectedIconTheme:可选参数,类型为 IconThemeData?,表示未选中图标主题。
  • selectedFontSize:可选参数,类型为 double,表示选中标签字体大小,默认为 14.0。
  • unselectedFontSize:可选参数,类型为 double,表示未选中标签字体大小,默认为 12.0。
  • selectedLabelStyle:可选参数,类型为 TextStyle?,表示选中标签样式。
  • unselectedLabelStyle:可选参数,类型为 TextStyle?,表示未选中标签样式。
  • showSelectedLabels:可选参数,类型为 bool?,表示是否显示选中标签。
  • showUnselectedLabels:可选参数,类型为 bool?,表示是否显示未选中标签。
  • mouseCursor:可选参数,类型为 MouseCursor?,表示鼠标指针样式。
  • enableFeedback:可选参数,类型为 bool?,表示是否启用反馈。
  • landscapeLayout:可选参数,类型为 BottomNavigationBarLandscapeLayout?,表示横向布局方式。
  • useLegacyColorScheme:可选参数,类型为 bool,表示是否使用旧颜色方案,默认为 true。
示例
class BottomPage extends StatefulWidget {
  @override
  _BottomPageState createState() => _BottomPageState();
}

class _BottomPageState extends State<BottomPage> {
  int _selectedIndex = 0;

  static const List<Widget> _widgetOptions = <Widget>[
    Text('Home Page',
        style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold)),
    Text('Search Page',
        style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold)),
    Text('Profile Page',
        style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold)),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('BottomNavigationBar Example')),
        body: Center(
          child: _widgetOptions.elementAt(_selectedIndex),
        ),
        bottomNavigationBar: BottomNavigationBar(
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: 'Home',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.search),
              label: 'Search',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.person),
              label: 'Profile',
            ),
          ],
          currentIndex: _selectedIndex,
          selectedItemColor: Colors.amber[800],
          onTap: _onItemTapped,
        ),
      ),
    );
  }
}

在这里插入图片描述
 
 

Drawer

Drawer 是抽屉导航,一般从屏幕左侧滑入,包含导航菜单项。

属性解析
const Drawer({
  super.key,
  this.backgroundColor,      // 抽屉的背景颜色
  this.elevation,            // 阴影高度
  this.shadowColor,          // 阴影颜色
  this.surfaceTintColor,     // 表面颜色
  this.shape,                // 形状
  this.width,                // 宽度
  this.child,                // 子控件
  this.semanticLabel,        // 语义标签
  this.clipBehavior,         // 剪切行为
});
  • key:用于标识控件的唯一值。
  • backgroundColor:可选参数,类型为 Color?,表示抽屉的背景颜色。
  • elevation:可选参数,类型为 double?,表示阴影高度。
  • shadowColor:可选参数,类型为 Color?,表示阴影颜色。
  • surfaceTintColor:可选参数,类型为 Color?,表示表面颜色。
  • shape:可选参数,类型为 ShapeBorder?,表示形状。
  • width:可选参数,类型为 double?,表示宽度。
  • child:可选参数,类型为 Widget?,表示子控件。
  • semanticLabel:可选参数,类型为 String?,表示语义标签。
  • clipBehavior:可选参数,类型为 Clip?,表示剪切行为。
示例
class ExamplePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text('Drawer Example'),
        ),
        body: Center(
          child: Text(
              'Swipe from the left or click on the menu icon to open the drawer.'),
        ),
        drawer: Drawer(
          backgroundColor: Colors.white,
          elevation: 16.0,
          child: ListView(
            padding: EdgeInsets.zero,
            children: <Widget>[
              DrawerHeader(
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
                child: Text(
                  'Drawer Header',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24,
                  ),
                ),
              ),
              ListTile(
                leading: Icon(Icons.home),
                title: Text('Home'),
                onTap: () {
                  // Handle the tap event here
                  Navigator.pop(context);
                },
              ),
              ListTile(
                leading: Icon(Icons.settings),
                title: Text('Settings'),
                onTap: () {
                  // Handle the tap event here
                  Navigator.pop(context);
                },
              ),
              ListTile(
                leading: Icon(Icons.contacts),
                title: Text('Contacts'),
                onTap: () {
                  // Handle the tap event here
                  Navigator.pop(context);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

在这里插入图片描述

 
 

示例

class FirstPage extends StatefulWidget {
  @override
  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage> {
  int _selectedIndex = 0;

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("First Page"),
      ),
      drawer: Drawer(
        child: ListView(
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              decoration: BoxDecoration(
                color: Colors.blue,
              ),
              child: Text(
                'Drawer Header',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 24,
                ),
              ),
            ),
            ListTile(
              leading: Icon(Icons.message),
              title: Text('Messages'),
              onTap: () {
                // Handle navigation
              },
            ),
            ListTile(
              leading: Icon(Icons.account_circle),
              title: Text('Profile'),
              onTap: () {
                // Handle navigation
              },
            ),
            ListTile(
              leading: Icon(Icons.settings),
              title: Text('Settings'),
              onTap: () {
                // Handle navigation
              },
            ),
          ],
        ),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                  builder: (context) =>
                      SecondPage(data: 'Hello from First Page')),
            );
          },
          child: Text('Go to Second Page'),
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.business),
            label: 'Business',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.school),
            label: 'School',
          ),
        ],
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.amber[800],
        onTap: _onItemTapped,
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  final String data;

  SecondPage({required this.data});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Second Page")),
      body: Center(child: Text(data)),
    );
  }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1923876.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

gorm只查询某一些字段字段的方法Select, 和只查询某一字段方法 Pluck

gorm中默认是查询所有字段的&#xff0c; 如果我们只需要获取某些字段的值&#xff0c;可以通过使用 Select方法来指定要查询的字段来实现&#xff0c; 也可以通过定义一个需要字段的结构体来实现&#xff1b; 而如果我们只需要查询某一个字段的值就可以使用 Pluck方法来获取(这…

【Python】一文向您详细介绍 `isinstance()` 的原理、作用和使用场景

【Python】一文向您详细介绍 isinstance() 的原理、作用和使用场景 下滑即可查看博客内容 &#x1f308; 欢迎莅临我的个人主页 &#x1f448;这里是我静心耕耘深度学习领域、真诚分享知识与智慧的小天地&#xff01;&#x1f387; &#x1f393; 博主简介&#xff1a;985…

【精品资料】数字乡村一体化解决方案(45页PPT)

引言&#xff1a;数字乡村一体化解决方案是响应国家乡村振兴战略&#xff0c;依托现代信息技术和数字经济理念&#xff0c;对乡村进行全面改造和升级的综合框架。该方案旨在通过数字化手段&#xff0c;推动乡村产业、治理、文化、教育、医疗等领域的协同发展&#xff0c;实现乡…

2024年【通信安全员ABC证】实操考试视频及通信安全员ABC证考试试题

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年通信安全员ABC证实操考试视频为正在备考通信安全员ABC证操作证的学员准备的理论考试专题&#xff0c;每个月更新的通信安全员ABC证考试试题祝您顺利通过通信安全员ABC证考试。 1、【单选题】.重大事故一般由事故…

智慧水利解决方案:从理论到实践的全面跨越,展示其在水资源管理、水灾害预警、水生态保护等方面的创新应用

目录 一、引言&#xff1a;智慧水利的时代背景与意义 二、智慧水利的理论框架与技术体系 1、理论框架 2、技术体系 三、智慧水利在水资源管理中的应用 1、水资源优化配置 2、水量水质协同管理 四、智慧水利在水灾害预警中的应用 1、洪水预警与应急响应 2、干旱监测与评…

【学党史、悟思想、办实事、开新局】学习《中国共产党历史》一、鸦片战争与近代中国社会的演变

历史是最好的教科书。学习党史、国史&#xff0c;是坚持和发展中国特色社会主义、把党和国家各项事业继续推向前进的必修课。 而我们作为普通群众&#xff0c;学习跟了解历史是我觉得可以做到的最基本东西&#xff0c;从前有过一段时间对历史特感兴趣&#xff0c;如中国古代史…

AI算法15-弹性网络回归算法Elastic Net Regression | ENR

弹性网络回归算法简介 在机器学习领域中&#xff0c;弹性网络&#xff08;Elastic Net&#xff09;是一种结合了L1范数&#xff08;套索回归&#xff09;和L2范数&#xff08;岭回归&#xff09;的正则化方法。它综合了两者的优点&#xff0c;既可以实现特征选择&#xff0c;又…

从“卷模型”到“卷应用”:AI时代的价值重塑与个性化智能探索

&#x1f308;所属专栏&#xff1a;【其它】✨作者主页&#xff1a; Mr.Zwq✔️个人简介&#xff1a;一个正在努力学技术的Python领域创作者&#xff0c;擅长爬虫&#xff0c;逆向&#xff0c;全栈方向&#xff0c;专注基础和实战分享&#xff0c;欢迎咨询&#xff01; 您的点…

Java基础之集合

集合和数组的类比 数组: 长度固定可以存基本数据类型和引用数据类型 集合: 长度可变只能存引用数据类型存储基本数据类型要把他转化为对应的包装类 ArrayList集合 ArrayList成员方法 添加元素 删除元素 索引删除 查询 遍历数组

mqtt.fx连接阿里云

本文主要是记述一下如何使用mqtt.fx连接在阿里云上创建好的MQTT服务。 1 根据MQTT填写对应端口即可 找到设备信息&#xff0c;里面有MQTT连接参数 2 使用物模型通信Topic&#xff0c;注意这里的post说设备上报&#xff0c;那也就是意味着云端订阅post&#xff1b;set则意味着设…

向量索引【草稿】

用「向量」化数据表示「概念」。 向量表达:概念上更为接近的点在空间中更为聚集,而概念上更为不同的点,则距离更远。 向量数学表达:以坐标原点为起点,这些坐标点重点。 在语言上应用–词向量。 一个训练恰当的词向量集合,将和指代的事物之间的向量集合十分接近。有利于自…

记一次 .NET某上位视觉程序 离奇崩溃分析

一&#xff1a;背景 1. 讲故事 前段时间有位朋友找到我&#xff0c;说他们有一个崩溃的dump让我帮忙看下怎么回事&#xff0c;确实有太多的人在网上找各种故障分析最后联系到了我&#xff0c;还好我一直都是免费分析&#xff0c;不收取任何费用&#xff0c;造福社区。 话不多…

IDEA启动Web项目总是提示端口占用

IDEA启动Web项目总是提示端口占用 一、前言 1.场景 IDEA启动Web项目总是提示端口占用&#xff1a; 确实是端口被占用&#xff0c;比如&#xff1a;没有正常关闭 Springboot 项目导致Springboot 项目换任何端口都提示端口占用&#xff0c;而且找不到占用端口的程序 2.环境 …

Qt中https的使用,报错TLS initialization failed和不能打开ssl.lib问题解决

前言 在现代应用程序中&#xff0c;安全地传输数据变得越来越重要。Qt提供了一套完整的网络API来支持HTTP和HTTPS通信。然而&#xff0c;在实际开发过程中&#xff0c;开发者可能会遇到SSL相关的错误&#xff0c;例如“TLS initialization failed”&#xff0c;cantt open ssl…

要注意!Google账号提示活动异常就要注意了,很可能下一步就是真•停用

很多朋友&#xff0c;在主动或被动登录谷歌账号时&#xff0c;被提醒账号活动异常&#xff0c;要验证手机号才能进一步使用谷歌账号&#xff0c;这是什么原因呢&#xff1f;如果不及时验证会出现什么状况呢&#xff0c;该如何解决这个问题呢&#xff1f;如果验证提示手机无法用…

一篇文章教你掌握——Pytorch深度学习实践基础

一篇文章教你掌握——Pytorch深度学习实践 1. Overview 概述1.1 Rule-based systems 基于规则的系统1.2 Classic machine learning 经典机器学习1.3 Representation learning 表征学习1.4 Brief history of neural networks 神经网络简史 2. 配置环境2.1 安装Anaconda2.2 创建虚…

[stm32f407]定时器使用

1.定时器定时串口打印 main.c #include "stm32f4xx.h" // Device header #include "serial.h" #include "delay.h" #include "tim.h"extern uint16_t count;int main(void) {Serial_Init();TIM_Init();printf(&quo…

通过AIGC赋能创意设计发展

随着人工智能技术的飞速发展&#xff0c;AIGC&#xff08;Artificial Intelligence Generated Content&#xff09;正逐渐成为创意设计领域的新引擎。AIGC通过智能算法与大数据的深度融合&#xff0c;不仅为设计师们提供了前所未有的创意灵感&#xff0c;还在设计方案优化等方面…

云计算数据中心(一)

目录 一、云数据中心的特征二、云数据中心网络部署&#xff08;一&#xff09;改进型树结构&#xff08;二&#xff09;递归层次结构&#xff08;三&#xff09;光交换网络&#xff08;四&#xff09;无线数据中心网络&#xff08;五&#xff09;软件定义网络 一、云数据中心的…