关键词搜索

源码搜索 ×
×

Vue笔记-Ant Design Vue的使用(Vue3)

发布2021-04-20浏览3455次

详情内容

这里文档要这样看:

这里

  1. npm install ant-design-vue@2.0.0-rc.3 -save
  2. npm install axios@0.21.0 --save

在main.js中添加antd.css及Antd

  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import Antd from 'ant-design-vue';
  4. import 'ant-design-vue/dist/antd.css';
  5. const app = createApp(App);
  6. app.use(Antd).mount('#app');

修改App.vue

  1. <template>
  2. <a-layout>
  3. <a-layout-header class="header">
  4. <div class="logo" />
  5. <a-menu
  6. theme="dark"
  7. mode="horizontal"
  8. v-model:selectedKeys="selectedKeys1"
  9. :style="{ lineHeight: '64px' }"
  10. >
  11. <a-menu-item key="1">nav 1</a-menu-item>
  12. <a-menu-item key="https://files.jxasp.com/image/2">nav 2</a-menu-item>
  13. <a-menu-item key="3">nav 3</a-menu-item>
  14. </a-menu>
  15. </a-layout-header>
  16. <a-layout>
  17. <a-layout-sider width="https://files.jxasp.com/image/200" style="background: #fff">
  18. <a-menu
  19. mode="inline"
  20. v-model:selectedKeys="selectedKeys2"
  21. v-model:openKeys="openKeys"
  22. :style="{ height: '100%', borderRight: 0 }"
  23. >
  24. <a-sub-menu key="sub1">
  25. <template #title>
  26. <span>
  27. <user-outlined />
  28. subnav 1
  29. </span>
  30. </template>
  31. <a-menu-item key="1">option1</a-menu-item>
  32. <a-menu-item key="https://files.jxasp.com/image/2">option2</a-menu-item>
  33. <a-menu-item key="3">option3</a-menu-item>
  34. <a-menu-item key="4">option4</a-menu-item>
  35. </a-sub-menu>
  36. <a-sub-menu key="sub2">
  37. <template #title>
  38. <span>
  39. <laptop-outlined />
  40. subnav 2
  41. </span>
  42. </template>
  43. <a-menu-item key="5">option5</a-menu-item>
  44. <a-menu-item key="6">option6</a-menu-item>
  45. <a-menu-item key="7">option7</a-menu-item>
  46. <a-menu-item key="8">option8</a-menu-item>
  47. </a-sub-menu>
  48. <a-sub-menu key="sub3">
  49. <template #title>
  50. <span>
  51. <notification-outlined />
  52. subnav 3
  53. </span>
  54. </template>
  55. <a-menu-item key="9">option9</a-menu-item>
  56. <a-menu-item key="10">option10</a-menu-item>
  57. <a-menu-item key="11">option11</a-menu-item>
  58. <a-menu-item key="12">option12</a-menu-item>
  59. </a-sub-menu>
  60. </a-menu>
  61. </a-layout-sider>
  62. <a-layout style="padding: 0 24px 24px">
  63. <a-breadcrumb style="margin: 16px 0">
  64. <a-breadcrumb-item>Home</a-breadcrumb-item>
  65. <a-breadcrumb-item>List</a-breadcrumb-item>
  66. <a-breadcrumb-item>App</a-breadcrumb-item>
  67. </a-breadcrumb>
  68. <a-layout-content
  69. :style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
  70. >
  71. Content
  72. </a-layout-content>
  73. </a-layout>
  74. </a-layout>
  75. </a-layout>
  76. </template>
  77. <script>
  78. import {defineComponent} from 'vue'
  79. export default defineComponent({
  80. name: 'app',
  81. components: {
  82. }
  83. });
  84. </script>
  85. <style>
  86. #components-layout-demo-top-side-2 .logo {
  87. float: left;
  88. width: 120px;
  89. height: 31px;
  90. margin: 16px 24px 16px 0;
  91. background: rgba(255, 255, 255, 0.3);
  92. }
  93. .ant-row-rtl #components-layout-demo-top-side-2 .logo {
  94. float: right;
  95. margin: 16px 0 16px 24px;
  96. }
  97. .site-layout-background {
  98. background: #fff;
  99. }
  100. </style>

程序运行截图如下:

 

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载