首页 > 其他分享 >2024.05.09 vue实现

2024.05.09 vue实现

时间:2024-05-22 12:07:57浏览次数:16  
标签:2024.05 vue name age 09 Person 10px

所花时间(包括上课):  1  h左右
代码量(行):    200   左右
搏客量(篇): 1
了解到的知识点:  vue2的选项式api
备注(其他):  
复制代码
<!--components文件中的Person.vue-->
<template>
    <div class="person">
        <h2>姓名:{{name}}</h2>
        <h2>年龄:{{age}}</h2>
        <button @click="changeName">修改名字</button>
        <button @click="changeAge">修改年龄</button>
        <button @click="showTel">查看联系方式</button>
    </div>
</template>

<script>
export default{
    name:'Person',
    data(){
        return{
            name:'张三',
            age: 18,
            tel:'13383619198'
        }
    },
    methods:{
        changeName(){
            this.name = 'zhang-san'
        },
        changeAge(){
            this.age += 1
        },
        showTel(){
            alert(this.tel)
        }
    }
}
</script>

<style scoped>
.person{
    background-color: skyblue;
    box-shadow: 0 0 10px;
    border-radius: 10px;
    padding:20px;
}
button{
    margin: 0 5px;
}
</style>
<!--App.vue-->
<template>
    <div class="app">
        <h1>你好啊!</h1>
        <Person/>                             这个是刚刚写的Person.vue
    </div>
</template>


<script>
import Person from './components/Person.vue'  这个是引入刚才写的Person.vue
    
 export default{
    name:'App',//组件名
    components:{Person}  把vue组件暴露出来
 }
</Script>

<style>
 .app{
    background-color:#ddd;
    box-shadow: 0 0 10px;
    border-radius: 10px;
    padding: 20px;
 }
</style>
 

标签:2024.05,vue,name,age,09,Person,10px
From: https://www.cnblogs.com/dmx-03/p/18205972

相关文章

  • 2024.05.08
    所花时间(包括上课): 2 h左右代码量(行): 200   左右搏客量(篇):1了解到的知识点: setup备注(其他): vue2中的data和methods可以与setup并列写,但是:data和methods可以利用this调用setup中的数据而,setup中,不能调用data和methods中的数据解释 ......
  • 2024.05.01
    学习时间1h代码量50行博客量1篇学习内容packagecom.example.demo22.mapper;importcom.example.demo22.entity.Article;importorg.apache.ibatis.annotations.Insert;importorg.apache.ibatis.annotations.Mapper;importorg.apache.ibatis.annotations.Se......
  • 2024.05.04
    学习时间1h代码行数50行博客量1篇学习内容packagecom.example.demo22.utils;importcom.auth0.jwt.JWT;importcom.auth0.jwt.algorithms.Algorithm;importjava.util.Date;importjava.util.Map;publicclassJwtUtils{privatestaticfinalStringKEY......
  • python0009
    对于给定5X5的整数矩阵,设计算法查找出所有的鞍点的信息(包括鞍点的值和行、列坐标,坐标从1开始)。提示:鞍点的特点:列上最小,行上最大。matrix=[]matrix2=[]matrix3=[]foriinrange(5):a=input()a1=a.split("")#a1中的元素都是字符串,需要转换fori......
  • vue路由切换滑动效果
    1.增加页面路由{path:'/feedbackList',name:'feedbackList',component:()=>import('../views/feedbackList/index'),meta:{title:"反馈列表",index:1}},{path:'/feedback......
  • uniapp-vue3-oadmin手机后台实例|vite5.x+uniapp多端仿ios管理系统
    原创vue3+uniapp+uni-ui跨端仿ios桌面后台OA管理模板Uni-Vue3-WeOS。uniapp-vue3-os一款基于uni-app+vite5.x+pinia等技术开发的仿ios手机桌面OA管理系统。实现了自定义桌面栅格磁贴布局、多分屏滑动管理、自定义桌面小部件、辅助触控悬浮球等功能。支持编译到H5+小程序端+App端......
  • .Net6 web API (跨域请求 Vue项目)
    前沿在做新项目的时候跨域2中选择一种是,.net .net //添加跨域策略builder.Services.AddCors(options=>{options.AddPolicy("CorsPolicy",opt=>opt.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().WithExposedHeaders("X-Pagina......
  • vue3插件(unplugin-auto-import自动引入的使用)
    1. vite.config文件里面1importAutoImportfrom'unplugin-auto-import/vite'23plugins:[4.......,5AutoImport({6include:[7/\.[tj]sx?$/,//.ts,.tsx,.js,.jsx8/\.vue$/,9/\.vue\?......
  • vue2的混入mixin使用
    前言vue3中不再推荐使用mixins!在Vue2中,mixins是创建可重用组件逻辑的主要方式。尽管在Vue3中保留了mixins支持,但对于组件间的逻辑复用,使用组合式API的组合式函数是现在更推荐的方式。参考文档:https://juejin.cn/post/7033424132427481101https://segmentfault.c......
  • 2024-05-21 Module not found: Error: Can't resolve 'ant-design-vue/dist/antd.css'
    报错:Modulenotfound:Error:Can'tresolve'ant-design-vue/dist/antd.css'in'xxx'原因:引入的antd.css文件实际上应该是reset.css文件,是由于ant-design-vue的官网给的代码和实际下的包的文件不一致导致。解决方案:把import"ant-design-vue/dist/antd.css";改成import"ant......