Ant Design Vue之布局layout
根据业务需要想直接用layout组件,实现如下效果:然后吧代码复制:<template><a-layout id="components-layout-demo-custom-trigger"><a-layout-sider v-model="collapsed" :trigger="null" collapsible><div class="logo"
·
根据业务需要想直接用layout组件,实现如下效果:
然后吧代码复制:
<template>
<a-layout id="components-layout-demo-custom-trigger">
<a-layout-sider v-model="collapsed" :trigger="null" collapsible>
<div class="logo" />
<a-menu theme="dark" mode="inline" :default-selected-keys="['1']">
<a-menu-item key="1">
<a-icon type="user" />
<span>nav 1</span>
</a-menu-item>
<a-menu-item key="2">
<a-icon type="video-camera" />
<span>nav 2</span>
</a-menu-item>
<a-menu-item key="3">
<a-icon type="upload" />
<span>nav 3</span>
</a-menu-item>
</a-menu>
</a-layout-sider>
<a-layout>
<a-layout-header style="background: #fff; padding: 0">
<a-icon
class="trigger"
:type="collapsed ? 'menu-unfold' : 'menu-fold'"
@click="() => (collapsed = !collapsed)"
/>
</a-layout-header>
<a-layout-content
:style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
>
Content
</a-layout-content>
</a-layout>
</a-layout>
</template>
<script>
export default {
data() {
return {
collapsed: false,
};
},
};
</script>
<style>
#components-layout-demo-custom-trigger .trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color 0.3s;
}
#components-layout-demo-custom-trigger .trigger:hover {
color: #1890ff;
}
#components-layout-demo-custom-trigger .logo {
height: 32px;
background: rgba(255, 255, 255, 0.2);
margin: 16px;
}
</style>
设置成全局组件方便调用,在main.js中添加:
然后运行查看结果:
报了这么一大堆错误,再看下文档,发现有个Layout.Sider的api,那就只能再把这个引用,然而不能带.点的,又各种一试各种报错,找了小度搜了一通也没搜到,最后终于自己测试出来方法,哈哈 ~ 也是自己菜了
再运行就不再一片红~
更多推荐
已为社区贡献6条内容
所有评论(0)