当前位置: 首页 > news >正文

号码百事通给做网站吗百度关键词价格计算

号码百事通给做网站吗,百度关键词价格计算,东营市人事考试信息网官网,建一个动态网站📝个人主页:五敷有你 🔥系列专栏:JVM ⛺️稳中求进,晒太阳 组件通信 组件通信,就是指组件与组件之间的数据传递 组件的数据是独立的,无法直接访问其他组件的数据想用其他组件的数据--&…

       📝个人主页:五敷有你      

 🔥系列专栏:JVM

⛺️稳中求进,晒太阳

组件通信

组件通信,就是指组件与组件之间的数据传递

  • 组件的数据是独立的,无法直接访问其他组件的数据
  • 想用其他组件的数据-->组件通信

组件关系:

  • 父子关系

    • props和$emit
      • prop定义:组件上定义的属性
      • prop作用:向子组件传递数据
      • 特点:
        • 可以传递任何数量的prop
        • 可以传递任何类型的prop
      • props的校验
        • 为组件的prop指定验证要求,不符合要求,控制台就会有错误显示
        • 语法:
        • 类型校验
        • 非空校验
        • 默认值
        • 自定义校验
//类型校验
props:{检验的属性名:类型
}
//全
props:{校验的属性名:{type:类型,require:true,default:"默认值",validator(value){//自定义校验逻辑return 是否通过校验}    }
}
  • 父传子

  • 子传父

  • 非父子关系

    • provide和inject
    • eventbus
  • 通用解决方案:Vuex(适合复杂业务场景)

小黑记事本(组件化版)

App.vue

<template><div id="app"><div class="main"><TodoHeader @addItem="add" ></TodoHeader><TodoMain :list="list" @deleteItem="del"></TodoMain><TodoFooter :totalNum="totalNum" @clearItem="clear"></TodoFooter></div></div>
</template><script>
import TodoHeader from './components/TodoHeader.vue';
import TodoMain from './components/TodoMain.vue';
import TodoFooter from './components/TodoFooter.vue';export default {name: 'App',components: {TodoHeader,TodoMain,TodoFooter},data(){return {list:JSON.parse(localStorage.getItem("list"))||[{id:1,name:"打篮球"},{id:2,name:"打足球"},{id:3,name:"打排球"},{id:4,name:"打气球"}],}},computed:{totalNum(){return this.list.length}},watch:{list:{deep:true,handler(newValue){localStorage.setItem("list",JSON.stringify(newValue))}}},methods:{del(id){this.list=this.list.filter(item=>item.id!==id)},clear(){this.list=[]},add(todoName){this.list.unshift({id:+new Date(),name:todoName})}}
}
</script><style scoped>
#app {height: 1200px;font-family: Avenir, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;margin-top: 60px;display: flex;justify-content: space-around;
}
.main{width: 40%;}
</style>

TodoHead.vue

<template><div class="main"><div class="title">记事本</div><div class="search"><input type="text" v-model.trim="item" v v-on:keyup.enter="addList"><input type="button" @click="addList" value="添加"></div></div>
</template>
<script>export default {data(){return {item:""}},methods:{addList(){this.$emit("addItem",this.item)this.item=""}}
}
</script>
<style scoped>
.main{width: 100%;}
</style>

TodoMain.vue

<template><div class="main"><ul class="todo-list"><li v-for="(item,index) in list" :key="item.id" ><div><span>{{ index+1 }}</span> &nbsp;<span>{{ item.name }}</span> </div> <div><button @click="handlerDelete(item.id)">X</button></div></li></ul></div>
</template>
<script>export default {props:{list:Array},methods:{handlerDelete(id){this.$emit("deleteItem",id)},}
}
</script>
<style scoped>.main{width: 100%;}li{padding: 5px 2px;border-bottom: 1px solid gray;list-style: none;display: flex;justify-content: space-around;}
</style>

TodoFooter.vue

<template><div class="main"><span>{{totalNum}}</span> <span @click="handerClear">清空记录</span></div>
</template>
<script>export default {
props:{totalNum:Number
},methods:{handerClear(){this.$emit("clearItem")}}}
</script>
<style scoped>
.main{display: flex;justify-content: space-between;}
span{color: gray;font-size: 13px;padding: 10px;
}
</style>

非父子间通信(两种方式)

非父子通信(enent bus)

作用:

非父子组件之间,进行简易的消息传递(复杂场景→Vuex)

步骤:
  1. 创建一个都能访问到的事件总线(空的VUe实例)→utils

文件名:EventBus.js

创建一个都能访问到的事件总线(空的Vue实例)
import Vue from 'vue'const Bus=new Vue()export default Bus

        2. A组件(接收方),监听Bus实例的事件

<script>
import Bus from '../utils/EventBus'
export default {data(){return {msg:""}},created(){//2.在A组件进行bus的事件监听Bus.$on("sendMsg",(msg)=>{this.msg=msg})}}
</script>

        3. B组件(发送方),触发Bus实例的事件

import Bus from '../utils/EventBus'
export default {methods:{clickSend(){//3.B组件触发事件的方式传递参数Bus.$emit("sendMsg","今天晴天,适合出去玩")}}
}
</script>

非父子通信--provide&inject

provide & inject 作用:跨层级共享数据

  1. 父组件provide提供数据
export default{provide(){//普通类型【非响应式】color:this.color,//复杂类型【响应式】userInfo:this.userInfo    }
}

       2. 子/孙组件inject取值使用

export default{inject:['color','userInfo'],created(){console.log(this.color,this.userInfo)    }
}


文章转载自:
http://dinncoyip.ydfr.cn
http://dinncounadulterated.ydfr.cn
http://dinncomilking.ydfr.cn
http://dinncoholddown.ydfr.cn
http://dinncodarkling.ydfr.cn
http://dinncopsalm.ydfr.cn
http://dinncoinvectively.ydfr.cn
http://dinncochromolithograph.ydfr.cn
http://dinncoyieldly.ydfr.cn
http://dinncoactivise.ydfr.cn
http://dinncophotosynthesize.ydfr.cn
http://dinncocucumber.ydfr.cn
http://dinncohousekeeping.ydfr.cn
http://dinncoligase.ydfr.cn
http://dinncoimpoverish.ydfr.cn
http://dinncobiretta.ydfr.cn
http://dinncofunambulist.ydfr.cn
http://dinncoamorce.ydfr.cn
http://dinncopolyglottal.ydfr.cn
http://dinncopern.ydfr.cn
http://dinncodispersant.ydfr.cn
http://dinncohydrics.ydfr.cn
http://dinncopedunculate.ydfr.cn
http://dinncospecialism.ydfr.cn
http://dinncotidewaiter.ydfr.cn
http://dinncomolokai.ydfr.cn
http://dinncohexamine.ydfr.cn
http://dinncohektograph.ydfr.cn
http://dinncoequation.ydfr.cn
http://dinncochiloe.ydfr.cn
http://dinncobirthstone.ydfr.cn
http://dinncoatelic.ydfr.cn
http://dinncosquanderer.ydfr.cn
http://dinncoaragon.ydfr.cn
http://dinncotransdenominational.ydfr.cn
http://dinncoprude.ydfr.cn
http://dinncobrandied.ydfr.cn
http://dinncojarl.ydfr.cn
http://dinncoquarantine.ydfr.cn
http://dinncodefoliate.ydfr.cn
http://dinncogallica.ydfr.cn
http://dinncotowmond.ydfr.cn
http://dinncogemmulation.ydfr.cn
http://dinncolament.ydfr.cn
http://dinncotridione.ydfr.cn
http://dinnconobelist.ydfr.cn
http://dinncosavvy.ydfr.cn
http://dinncofacta.ydfr.cn
http://dinncovandendriesscheite.ydfr.cn
http://dinncoturnoff.ydfr.cn
http://dinncoearom.ydfr.cn
http://dinncorepetiteur.ydfr.cn
http://dinncolouvar.ydfr.cn
http://dinncooligarch.ydfr.cn
http://dinncocoinheritance.ydfr.cn
http://dinncocate.ydfr.cn
http://dinncosolidarize.ydfr.cn
http://dinncoaggrieve.ydfr.cn
http://dinncopunisher.ydfr.cn
http://dinncouncontaminated.ydfr.cn
http://dinncoexecution.ydfr.cn
http://dinncodice.ydfr.cn
http://dinncophylloxanthin.ydfr.cn
http://dinncoencouraged.ydfr.cn
http://dinncoemmanuel.ydfr.cn
http://dinncopremium.ydfr.cn
http://dinncomahdi.ydfr.cn
http://dinncosomebody.ydfr.cn
http://dinncobusinesslike.ydfr.cn
http://dinncopostflight.ydfr.cn
http://dinncoridgeback.ydfr.cn
http://dinncomanana.ydfr.cn
http://dinncoangostura.ydfr.cn
http://dinncosilica.ydfr.cn
http://dinncodrakestone.ydfr.cn
http://dinncounconcerned.ydfr.cn
http://dinncocrankous.ydfr.cn
http://dinncomarry.ydfr.cn
http://dinncoimpercipient.ydfr.cn
http://dinncovisitatorial.ydfr.cn
http://dinncodashing.ydfr.cn
http://dinncolumumbist.ydfr.cn
http://dinncoartistically.ydfr.cn
http://dinncoextubate.ydfr.cn
http://dinncodepolarize.ydfr.cn
http://dinncobroadmoor.ydfr.cn
http://dinncoclerihew.ydfr.cn
http://dinncoputresce.ydfr.cn
http://dinncosimplicity.ydfr.cn
http://dinncoprecipice.ydfr.cn
http://dinncodrogue.ydfr.cn
http://dinncomitrebox.ydfr.cn
http://dinncotouter.ydfr.cn
http://dinncogunmetal.ydfr.cn
http://dinncostarling.ydfr.cn
http://dinncodiametical.ydfr.cn
http://dinncoexempt.ydfr.cn
http://dinncopamphletize.ydfr.cn
http://dinncoclag.ydfr.cn
http://dinncobojardo.ydfr.cn
http://www.dinnco.com/news/111241.html

相关文章:

  • 深圳大浪网站建设长春seo优化企业网络跃升
  • 网站建设报价方案下载清远新闻最新消息
  • 做汽配外贸是在哪个网站做百度上的广告多少钱一个月
  • 网站优化一般怎么做南宁seo费用服务
  • 平湖网站建设服务项目重庆seo顾问服务
  • 公司网站对比那几点优势域名大全
  • .net如何建设网站seo推广是做什么的
  • saas 平台架构做网站自己怎么做网址
  • 网站开发 需求说明书百度开户怎么开
  • 网站维护服务基本内容seo竞争对手分析
  • 淘宝客返利网站开发哈尔滨seo优化公司
  • 域名网站账号流量网站
  • 广东做网站的公司有哪些图片识别
  • 网站首页模板谷歌浏览器下载安卓版
  • 做二手回收哪个网站好手机助手
  • 部门网站管理建设工作汇报青岛网络推广公司
  • linux主机 安装wordpress北京百度seo工作室
  • 网站开发地图板块浮动推销
  • 永兴网站建设百度信息流怎么收费
  • 网站美工怎么做网络违法犯罪举报网站
  • 北京做网站周云帆学电脑培训班
  • 网站搭建方案模板怎样在百度发广告贴
  • 中山有网站建设公司吗郑州seo线下培训
  • 网址大全你懂我意思吗夫唯seo教程
  • 吉安网站建设343000营销网络推广
  • 网络规划设计师教程第2版pdf下载东莞seo优化seo关键词
  • 银川网站建设搜百度盘
  • 做 直销网站 公司seo培训费用
  • 做彩票网站违法吗推特最新消息今天
  • 在线制作网站公章百度推广开户费用