Vue3组件开发学习中有哪些知识点要掌握了解
Admin 2022-06-20 群英技术资讯 1052 次浏览
这篇文章主要介绍了Vue3组件开发学习中有哪些知识点要掌握了解相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Vue3组件开发学习中有哪些知识点要掌握了解文章都会有所收获,下面我们一起来看看吧。果然长时间坐着或站着,会给腰带来很大负担,声明下我不是腰脱,就是个穿刺手术而已,身上有多处缝针没长好,所以会给肚子和腰带来一定的负担。
上一篇文章已经写了关于布局的开发,传送门《Vue3(三)网站首页布局开发 》,但是我们写代码,肯定是继承了优秀的代码风格,封装的特性,所以这里我们再对代码进行修改,抽离公共部分的footer和header部分。
header和footer是公共的部分,每个页面都有,所以要抽离出来,然后后续的维护再App.vue中维护即可。
在components下创建组件,基本结构如下:

由template和script两对标签构成

如上图红圈部分所示,就是我们要进行抽离的公共部分,即组件的开发。
在components下创建组件,header部分组件代码如下:
html
<template>
<a-layout-header class="header">
<div class="logo" />
<a-menu
theme="dark"
mode="horizontal"
v-model:selectedKeys="selectedKeys1"
:style="{ lineHeight: '64px' }"
>
<a-menu-item key="1">nav 11122</a-menu-item>
<a-menu-item key="2">nav 2</a-menu-item>
<a-menu-item key="3">nav 3</a-menu-item>
</a-menu>
</a-layout-header>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'TheHeader',
});
</script>

如上图所示,就是我们要footer部分组件的开发,示例代码如下:
html
<template>
<a-layout-footer style="text-align: center">
软件测试君 ©2021 Created by 六哥20211017
</a-layout-footer>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'TheFooter',
});
</script>
示例代码如下:
html
<template>
<a-layout>
<the-header></the-header>
<router-view/>
<the-footer></the-footer>
</a-layout>
</template>
<style>
#components-layout-demo-top-side-2 .logo {
float: left;
width: 120px;
height: 31px;
margin: 16px 24px 16px 0;
background: rgba(255, 255, 255, 0.3);
}
.ant-row-rtl #components-layout-demo-top-side-2 .logo {
float: right;
margin: 16px 0 16px 24px;
}
.site-layout-background {
background: #fff;
}
</style>
<script>
import TheHeader from "@/components/the-header";
import TheFooter from "@/components/the-footer";
export default {
components: {
TheHeader,
TheFooter
}
}
</script>
home修改如下:
html
<template>
<a-layout>
<a-layout-sider width="200" style="background: #fff">
<a-menu
mode="inline"
v-model:selectedKeys="selectedKeys2"
v-model:openKeys="openKeys"
:style="{ height: '100%', borderRight: 0 }"
>
<a-sub-menu key="sub1">
<template #title>
<span>
<user-outlined />
subnav 1
</span>
</template>
<a-menu-item key="1">option1</a-menu-item>
<a-menu-item key="2">option2</a-menu-item>
<a-menu-item key="3">option3</a-menu-item>
<a-menu-item key="4">option4</a-menu-item>
</a-sub-menu>
<a-sub-menu key="sub2">
<template #title>
<span>
<laptop-outlined />
subnav 2
</span>
</template>
<a-menu-item key="5">option5</a-menu-item>
<a-menu-item key="6">option6</a-menu-item>
<a-menu-item key="7">option7</a-menu-item>
<a-menu-item key="8">option8</a-menu-item>
</a-sub-menu>
<a-sub-menu key="sub3">
<template #title>
<span>
<notification-outlined />
subnav 3
</span>
</template>
<a-menu-item key="9">option9</a-menu-item>
<a-menu-item key="10">option10</a-menu-item>
<a-menu-item key="11">option11</a-menu-item>
<a-menu-item key="12">option12</a-menu-item>
</a-sub-menu>
</a-menu>
</a-layout-sider>
<a-layout-content
:style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
>
Content
</a-layout-content>
</a-layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'Home',
});
</script>
重新编译,再次访问页面结果如下:

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
目录在data里引入相对路径问题解决如何在data中正常引入图片路径此时有两种解决方法在data里引入相对路径问题在项目的HTML中引入图片的相对路径,这样写是能找到图片显示出来的:img src=../../../static/img/step-ongoing.png但图片太多感觉太乱了了,想在data中通过变量统一
这篇文章主要为大家详细介绍了JavaScript实现移动端签字功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
最近在做商城类的项目,需要使用到客服系统,用户选择的腾讯IM即时通信,所以本文主要介绍了vue实现集成腾讯TIM即时通讯,感兴趣的可以了解一下
jquery修改某一行值的方法:1、利用eq()方法获取指定行元素对象,语法为“元素对象.eq(行元素的索引)”;2、利用html()方法来修改已获取到指定行元素对象的值,语法为“行元素对象.html(修改后的值)”。
在react中的三大属性有state、props、refs,这篇文章给大家分享的是有关react的refs属性的内容,小编觉得挺实用的,因此分享给大家做个参考,接下来一起跟随小编看看吧。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008