• vue快速学习03、ant-design


    vue快速学习03、ant-design

    目录

    vue快速学习03、ant-design

    1、安装环境

    2、a-button&a-icon

    3、message消息提示

    4、a-layout布局

    5、a-menu菜单

    6、a-button-group

    7、a-row&a-col

    8、a-input、a-textarea、a-input-number、a-radio-group、a-rate、a-select、a-spin

    9、rules

    10、a-tree

    11、a-table


    1、安装环境

    vue快速学习03、ant-design-Node.js文档类资源-CSDN下载

    包含内容:antd.min.css、antd.min.js、vue.min.js。

    备注:引入顺序

    1. <!-- vue_css环境 -->
    2. <link rel="stylesheet" href="css/antd.min.css">
    3. <!-- vue环境 -->
    4. <script src="js/vue.min.js"></script>
    5. <!-- antd环境 -->
    6. <script src="js/antd.min.js"></script>

    2、a-button&a-icon

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <!-- 视图层 -->
    12. <div id="app">
    13. <a-button type="primary">默认</a-button>
    14. <a-button type="danger">默认</a-button>
    15. <a-button size="small">默认</a-button>
    16. <a-button size="large">默认</a-button>
    17. <a-button shape="circle">默认</a-button>
    18. <a-button shape="round">默认</a-button>
    19. <a-button loading>默认</a-button>
    20. <a-button disabled>默认</a-button>
    21. <a-button ghost>默认</a-button>
    22. <a-button htmlType="type">默认</a-button>
    23. <a-icon type="message"></a-icon>
    24. <a-icon type="edit"></a-icon>
    25. <a-icon type="block"></a-icon>
    26. <a-icon type="key"></a-icon>
    27. <a-icon type="wifi"></a-icon>
    28. <a-icon type="wechat"></a-icon>
    29. <a-icon type="qq" style="font-size: 3rem;"></a-icon>
    30. <a-icon type="taobao"></a-icon>
    31. <a-icon type="zhihu"></a-icon>
    32. <a-icon type="ie"></a-icon>
    33. <a-icon type="book"></a-icon>
    34. </div>
    35. <!-- vue环境 -->
    36. <script src="js/vue.min.js"></script>
    37. <!-- antd环境 -->
    38. <script src="js/antd.min.js"></script>
    39. <script>
    40. new Vue({
    41. el: "#app"
    42. })
    43. </script>
    44. </body>
    45. </html>

    3、message消息提示

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <p>请输入用户名:
    13. <a-input type="text" v-model="userName" placeholder="请输入用户名" /></p>
    14. <p>
    15. <a-button type="danger" v-on:click="test">点击测试</a-button>
    16. </p>
    17. </div>
    18. <!-- 引入vue环境 -->
    19. <script src="js/vue.min.js"></script>
    20. <!-- antd环境 -->
    21. <script src="js/antd.min.js"></script>
    22. <script>
    23. new Vue({
    24. el: "#app",
    25. data: {
    26. userName: ""
    27. },
    28. methods: {
    29. test: function() {
    30. this.$message.success("操作成功" + this.userName);
    31. this.$message.error("错误提示" + this.userName);
    32. this.$message.info("信息提示" + this.userName);
    33. this.$message.warning("异常提示" + this.userName);
    34. this.$message.loading("等待" + this.userName);
    35. }
    36. }
    37. })
    38. </script>
    39. </body>
    40. </html>

    4、a-layout布局

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. <style>
    10. .ant-layout-sider-children {
    11. color: white;
    12. }
    13. .ant-layout-header {
    14. color: white;
    15. }
    16. .ant-layout-content {
    17. background-color: aqua;
    18. height: 100px;
    19. }
    20. .ant-layout-footer {
    21. color: white;
    22. background-color: black;
    23. }
    24. </style>
    25. </head>
    26. <body>
    27. <div id="app">
    28. <!-- 左上中下结构 -->
    29. <a-layout>
    30. <a-layout-sider>标题</a-layout-sider>
    31. <a-layout>
    32. <a-layout-header>头部</a-layout-header>
    33. <a-layout-content>身子</a-layout-content>
    34. <a-layout-footer></a-layout-footer>
    35. </a-layout>
    36. </a-layout>
    37. <hr/>
    38. <a-layout>
    39. <a-layout>
    40. <a-layout-header>头部</a-layout-header>
    41. </a-layout>
    42. <a-layout>
    43. <a-layout-sider>菜单</a-layout-sider>
    44. <a-layout-content>身子</a-layout-content>
    45. </a-layout>
    46. <a-layout-footer></a-layout-footer>
    47. </a-layout>
    48. <hr/>
    49. <a-layout>
    50. <a-layout>
    51. <a-layout-header>头部</a-layout-header>
    52. </a-layout>
    53. <a-layout>
    54. <a-layout-content>身子</a-layout-content>
    55. <a-layout-sider>菜单</a-layout-sider>
    56. </a-layout>
    57. <a-layout-footer></a-layout-footer>
    58. </a-layout>
    59. <hr/>
    60. <a-layout>
    61. <a-layout-header></a-layout-header>
    62. <a-layout-content>身子</a-layout-content>
    63. <a-layout-footer></a-layout-footer>
    64. </a-layout>
    65. </div>
    66. <!-- 引入vue -->
    67. <script src="js/vue.min.js"></script>
    68. <!-- antd -->
    69. <script src="js/antd.min.js"></script>
    70. <script>
    71. new Vue({
    72. el: "#app"
    73. })
    74. </script>
    75. </body>
    76. </html>

    5、a-menu菜单

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <a-menu style="width:50%" mode="inline" theme="dark">
    13. <a-menu-item>银行金库</a-menu-item>
    14. <a-sub-menu>
    15. <a-menu-item>库尔勒金库</a-menu-item>
    16. <a-sub-menu>
    17. <a-menu-item>南库</a-menu-item>
    18. <a-menu-item>北库</a-menu-item>
    19. </a-sub-menu>
    20. <a-menu-item>咸阳金库</a-menu-item>
    21. </a-sub-menu>
    22. <a-menu-item>包袋单位</a-menu-item>
    23. <a-sub-menu>
    24. <a-menu-item>50元纸币/包袋100万</a-menu-item>
    25. <a-menu-item>100元纸币/包袋200万</a-menu-item>
    26. </a-sub-menu>
    27. </a-menu>
    28. <hr/>
    29. <!-- 面包屑 -->
    30. <a-breadcrumb>
    31. <a-breadcrumb-item>首页</a-breadcrumb-item>
    32. <a-breadcrumb-item>导航</a-breadcrumb-item>
    33. <a-breadcrumb-item>母婴用品</a-breadcrumb-item>
    34. <a-breadcrumb-item>尿不湿</a-breadcrumb-item>
    35. <a-breadcrumb-item>婴幼儿尿不湿</a-breadcrumb-item>
    36. <a-breadcrumb-item>婴幼儿拉拉裤</a-breadcrumb-item>
    37. </a-breadcrumb>
    38. </div>
    39. <script src="js/vue.min.js"></script>
    40. <script src="js/antd.min.js"></script>
    41. <script>
    42. new Vue({
    43. el: "#app"
    44. })
    45. </script>
    46. </body>
    47. </html>

    6、a-button-group

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app" style="width:30%;height:60vh;margin:50px auto">
    12. <div>
    13. <p>
    14. <a-input type="text" v-model="showText" placeholder="0" style="border:1px solid black;text-align: right" />
    15. </p>
    16. </div>
    17. <div style="width:90%;margin:0px auto">
    18. <p>
    19. <a-button-group style="width:100%">
    20. <a-button style="width:33%" type="danger" v-on:click="inN(7)">7</a-button>
    21. <a-button style="width:33%" type="danger" v-on:click="inN(8)">8</a-button>
    22. <a-button style="width:33%" type="danger" v-on:click="inN(9)">9</a-button>
    23. </a-button-group>
    24. </p>
    25. <p>
    26. <a-button-group style="width:100%">
    27. <a-button style="width:33%" type="danger" v-on:click="inN(4)">4</a-button>
    28. <a-button style="width:33%" type="danger" v-on:click="inN(5)">5</a-button>
    29. <a-button style="width:33%" type="danger" v-on:click="inN(6)">6</a-button>
    30. </a-button-group>
    31. </p>
    32. <p>
    33. <a-button-group style="width:100%">
    34. <a-button style="width:33%" type="danger" v-on:click="inN(1)">1</a-button>
    35. <a-button style="width:33%" type="danger" v-on:click="inN(2)">2</a-button>
    36. <a-button style="width:33%" type="danger" v-on:click="inN(3)">3</a-button>
    37. </a-button-group>
    38. </p>
    39. <p>
    40. <a-button-group style="width:100%">
    41. <a-button style="width:33%" type="danger" v-on:click="inN(0)">0</a-button>
    42. <a-button style="width:33%" type="danger" v-on:click="ysf('+')">+</a-button>
    43. <a-button style="width:33%" type="danger" v-on:click="ysf('-')">-</a-button>
    44. </a-button-group>
    45. </p>
    46. <p>
    47. <a-button type="primary" style="width:100%" v-on:click="result">=</a-button>
    48. </p>
    49. <p>
    50. <a-button type="primary" style="width:100%" v-on:click="resetNu">C</a-button>
    51. </p>
    52. </div>
    53. </div>
    54. <script src="js/vue.min.js"></script>
    55. <script src="js/antd.min.js"></script>
    56. <script>
    57. new Vue({
    58. el: "#app",
    59. data: {
    60. showText: "",
    61. logYsf: "",
    62. cache: 0
    63. },
    64. methods: {
    65. inN: function(o) {
    66. this.showText += o + "";
    67. },
    68. ysf: function(o) { //运算符
    69. this.cache = this.showText;
    70. this.showText = 0;
    71. this.logYsf = o;
    72. },
    73. result: function() {
    74. if (this.logYsf == "+") {
    75. this.showText = parseInt(this.showText) + parseInt(this.cache);
    76. } else if (this.logYsf == "-") {
    77. this.showText = parseInt(this.cache) - parseInt(this.showText);
    78. }
    79. this.$message.success("计算成功");
    80. },
    81. resetNu: function() {
    82. this.cache = "";
    83. this.showText = 0;
    84. this.logYsf = "";
    85. }
    86. }
    87. })
    88. </script>
    89. </body>
    90. </html>

    7、a-row&a-col

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <a-row style="background-color: skyblue;">
    13. <a-col :span="12" style="background-color: hotpink;height: 5vh;"></a-col>
    14. <a-col :span="12"></a-col>
    15. </a-row>
    16. <hr/>
    17. <a-row style="background-color: skyblue;">
    18. <a-col :span="2" style="background-color: hotpink;height: 5vh;"></a-col>
    19. <a-col :span="6" style="background-color: blue;height: 5vh;"></a-col>
    20. <a-col :span="5"></a-col>
    21. <a-col :span="3" style="background-color: hotpink;height: 5vh;"></a-col>
    22. <a-col :span="8" style="background-color: blue;height: 5vh;"></a-col>
    23. </a-row>
    24. <hr/>
    25. <a-row>
    26. <a-row>
    27. <a-col :span="24" style="background-color: red;height: 5vh;"></a-col>
    28. </a-row>
    29. <a-row>
    30. <a-col :span="4" style="background-color: gray;height: 25vh;"></a-col>
    31. <a-col :span="20" style="background-color: yellow;height: 25vh;"></a-col>
    32. </a-row>
    33. <a-row>
    34. <a-col :span="24" style="background-color: blue;height: 5vh;"></a-col>
    35. </a-row>
    36. </a-row>
    37. </div>
    38. <script src="js/vue.min.js"></script>
    39. <script src="js/antd.min.js"></script>
    40. <script>
    41. new Vue({
    42. el: "#app"
    43. })
    44. </script>
    45. </body>
    46. </html>

    8、a-input、a-textarea、a-input-number、a-radio-group、a-rate、a-select、a-spin

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <a-input style="text-align: right" prefix="¥" suffix="元"></a-input>
    13. <a-input-search></a-input-search><br/>
    14. <a-textarea></a-textarea>
    15. <a-input-number></a-input-number>
    16. <a-input-number size="large"></a-input-number>
    17. <a-input-number size="small"></a-input-number>
    18. <a-radio-group>
    19. <a-radio :value="1"></a-radio>
    20. <a-radio :value="0"></a-radio>
    21. </a-radio-group>
    22. <a-rate :default-value="2.5" allow-half></a-rate>
    23. <a-select default-value="汉族" style="width:100px">
    24. <a-select-option key="1" value="1" disabled>汉族</a-select-option>
    25. <a-select-option key="1" value="2">傣族</a-select-option>
    26. </a-select>
    27. <a-spin></a-spin>
    28. </div>
    29. <script src="js/vue.min.js"></script>
    30. <script src="js/antd.min.js"></script>
    31. <script>
    32. new Vue({
    33. el: "#app"
    34. })
    35. </script>
    36. </body>
    37. </html>

    9、rules

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <!-- 如果未初始化过form无法使用 -->
    13. <a-form :form="form">
    14. <a-form-item label="用户名">
    15. <!-- 验证的书写格式-->
    16. <a-input v-decorator="['userName',
    17. { rules: [{ required: true, message: '用户名不能为空!' }] } ]" />
    18. </a-form-item>
    19. </a-form>
    20. </div>
    21. <script src="js/vue.min.js"></script>
    22. <script src="js/antd.min.js"></script>
    23. <script>
    24. new Vue({
    25. el: "#app",
    26. beforeCreate() { //1、初始化创建form
    27. this.form = this.$form.createForm(this);
    28. }
    29. })
    30. </script>
    31. </body>
    32. </html>

    10、a-tree

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <a-tree v-bind="attrs"></a-tree>
    13. </div>
    14. <script src="js/vue.min.js"></script>
    15. <script src="js/antd.min.js"></script>
    16. <script>
    17. new Vue({
    18. el: "#app",
    19. data: {
    20. attrs: {
    21. treeData: [{
    22. title: "新闻一部",
    23. key: "new1",
    24. children: [{
    25. title: "新华社消息",
    26. key: "new1-1"
    27. }, {
    28. title: "路透社消息",
    29. key: "new1-2"
    30. }, {
    31. title: "路透社消息",
    32. key: "new1-3"
    33. }]
    34. }, {
    35. title: "新闻二部",
    36. key: "new2",
    37. children: [{
    38. title: "新华社消息",
    39. key: "new2-1"
    40. }, {
    41. title: "路透社消息",
    42. key: "new2-2"
    43. }, {
    44. title: "路透社消息",
    45. key: "new2-3"
    46. }]
    47. }, ]
    48. }
    49. }
    50. })
    51. </script>
    52. </body>
    53. </html>

    11、a-table

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="css/antd.min.css">
    9. </head>
    10. <body>
    11. <div id="app">
    12. <a-table v-bind="attrs" :columns="columns">
    13. <!-- slot-scope="text"是传递值的方式 -->
    14. <td>
    15. <span slot="id" slot-scope="text">
    16. <a-button type="danger" v-on:click="del(text)">删除</a-button>
    17. </span>
    18. </td>
    19. </a-table>
    20. </div>
    21. <script src="js/vue.min.js"></script>
    22. <script src="js/antd.min.js"></script>
    23. <script>
    24. new Vue({
    25. el: "#app",
    26. data: {
    27. columns: [{
    28. title: "编号", //显示的名称
    29. dataIndex: "id", //绑定的数据,
    30. key: "id", //关键字
    31. align: "center", //位置
    32. width: "50px", //设置宽度
    33. }, {
    34. title: "姓名", //显示的名称
    35. dataIndex: "name", //绑定的数据,
    36. key: "name", //关键字
    37. align: "center", //位置
    38. width: "100px" //设置宽度
    39. }, {
    40. title: "详情", //显示的名称
    41. dataIndex: "info", //绑定的数据,
    42. key: "info", //关键字
    43. align: "center", //位置
    44. width: "150px" //设置宽度
    45. },{
    46. title: "操作", //显示的名称
    47. dataIndex: "id", //绑定的数据,
    48. key: "id", //关键字
    49. align: "center", //位置
    50. width: "50px", //设置宽度
    51. scopedSlots: { //声明功能
    52. customRender: "id"
    53. }
    54. }
    55. ],
    56. attrs: {
    57. dataSource: [{
    58. id: 1,
    59. name: "李春梦",
    60. info: "管钱的,百度2班大管家。"
    61. }, {
    62. id: 2,
    63. name: "杨建强",
    64. info: "百度2班大班长,争取大创拿个金奖回来。"
    65. }, {
    66. id: 3,
    67. name: "王泽细",
    68. info: "政委,一个身负重担的精致女子。"
    69. }, {
    70. id: 4,
    71. name: "李勇",
    72. info: "虽然不是班委,但是很好用。话少,活好。"
    73. }],
    74. rowkey: "id"
    75. },
    76. },
    77. methods: {
    78. del: function(o) {
    79. for (var index = 0; index < this.attrs.dataSource.length; index++) {
    80. const element = this.attrs.dataSource[index];
    81. if (element.id == o) {
    82. this.attrs.dataSource.splice(index, 1);
    83. }
    84. }
    85. this.$message.success("删除成功");
    86. }
    87. }
    88. })
    89. </script>
    90. </body>
    91. </html>

    基础操作演示完毕,有需要可以自己去搜索antd的全部功能。

  • 相关阅读:
    【Angular1】基础使用及各类方法
    [职场] 求职如何设置预期 #笔记#经验分享
    12.面试题——Spring Boot
    Jetson Nano上jtop(jetson_stats.service)不能运行
    用Python来开发安卓程序:(1)BeeWare安卓开发环境的搭建
    视频怎么消除人声?一款视频去人声软件,轻松去除视频人声
    万宾科技智能井盖传感器,预防城市道路安全
    企业如何做源代码保护措施
    Linux性能优化方案
    调试 Mahony 滤波算法的思考 10
  • 原文地址:https://blog.csdn.net/feng8403000/article/details/125450680