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

网页qq直接登陆茂名seo快速排名外包

网页qq直接登陆,茂名seo快速排名外包,石家庄经济,php做网站中下一步按钮子组件接受父组件传递的事件 1.子组件使用事件名"$emit(父组件中传递的事件名,想给父组件传递的参数(可选))" click"$emit(click)" 2.子组件使用 v-on"$listeners" 父组件&#xff1a; <template><div id"app"><myCo…
  • 子组件接受父组件传递的事件

1.子组件使用@事件名="$emit('父组件中传递的事件名',想给父组件传递的参数(可选))"
@click="$emit('click')"
2.子组件使用
v-on="$listeners"

 父组件:

<template><div id="app"><myComponents :msg="form.msg" @click="a"/></div>
</template><script>
import myComponents from "./components/myComponents";export default {name: 'App',components: {myComponents},data(){return {form:{msg: "10"}}},methods:{a(){console.log('哈哈哈')},}
}
</script><style></style>

 子组件:

<template><div><!-- 子组件接收父组件传来的参数--><h1 v-on="$listeners" @click="$emit('click')">{{ msg }}</h1></div>
</template><script>
export default {name: 'my-Components',props: {msg: {type: String,default: "18"}},created() {console.log(this.$listeners)  //一个对象,里面包含父组件传递过来的所有事件},methods: {}
}
</script>
<style scoped>
</style>
  • 父组件传值给子组件

1.子组件使用props声明想要的属性,再将该属性动态绑定给子组件
props: {msg: {type: String,default: "18"},
},
     然后子组件中绑定数据即可
    父组件使用prop声明,就可以传递给子组件

:prop="msg"

2.子组件使用$attrs,这个组件包含了被传入,但没有声明的prop

 子组件:

<template><div><!-- 子组件接收父组件传来的参数--><h1>{{ msg }}</h1></div>
</template><script>
export default {name: 'my-Components',
//不声明msg// props: {//   msg: {//     type: String,//     default: "18"//   },// },created() {console.log(this.$attrs)   //一个对象,包含父组件中被传入,但没有声明的prop},methods: {}
}
</script><style scoped>
</style>

打印结果: 

 此时h1标签上就有msg属性:

<template><div><!-- 子组件接收父组件传来的参数--><h1 v-bind="$attrs"> {{this.$attrs.msg}}</h1></div>
</template>

页面显示结果:

 

 需要注意的一点是:Vue会将被传入,但未声明的prop作为html属性,绑定到组件的根元素上:

可以设置属性 inheritattrs为false,将这些默认行为去掉,来解决这个问题。

<template><div><!-- 子组件接收父组件传来的参数--><h1 v-bind="$attrs"> {{this.$attrs.msg}}</h1></div>
</template><script>
export default {name: 'my-Components',inheritAttrs:false,
}
</script><style scoped>
</style>

  • 对外暴露子组件插槽

1.直接向子组件转发插槽,使用父组件的 $slots 
该组件包含了传递给父组件的非作用域插槽
使用$scopeSlots可传递给父组件的作用域插槽,这个组件包含了组件接受的所有插槽

子组件:

<template>
<el-input
v-model="innerVal"
v-bind-"$attrs
@input="$emit('input", $event)"v-on-"$listeners//子组件中写两个插槽
<template #append>
<slot name="append"></slot></template>
<template #prepend>
<slot name="prepend"></slot></template>
</el-input>
</template>

 打印this.$slots

  • props validator

一般我们会用对象的形式声明prop,可以在对象中指定prop的默认值,也可以指定类型,对prop进行验证。
一个更灵活的的方式是,传入并编写一个验证函数,prop会作为参数传入该函数,函数返回fals时,会抛出控制台警告,这种方式特别适合验证枚举值,

 子组件:

<template><div><!-- 子组件接收父组件传来的参数--><h1 v-on="$listeners" @click="$emit('click')" v-bind="$attrs"> {{this.$attrs.msg}}</h1></div>
</template><script>
export default {name: 'my-Components',inheritAttrs:false,props:{numberIs:{default: '1',//当传入的prop值不是1,2,3时,控制台会抛出警告validator: prop => ['1', '2', '3'].includes(prop)}},
}
</script>
<style scoped>
</style>

 父组件:

<template><div id="app"><!--  传入numberIs的值为4  --><myComponents :msg="form.msg" @click="a" numberIs="4"/></div>
</template><script>
import myComponents from "./components/myComponents";export default {name: 'App',components: {myComponents},data() {return {form: {msg: "10"},}},methods: {a() {console.log('哈哈哈')},}
}
</script><style></style>

$refs用于父组件获取整个子组件,然后可以使用子组件的方法和属性(暴露子组件方法)

父组件:

<template><div id="app"><!--  ref相当于给当前子组件设置了一个id,可以使用refs根据ref的值获取该组件  --><myComponents :msg="form.msg" @click="a" numberIs="1" ref="bb"/></div>
</template><script>
import myComponents from "./components/myComponents";export default {name: 'App',components: {myComponents},data() {return {form: {msg: "10"},}},methods: {a() {//获取ref值为bb的子组件,并调用该子组件上的show方法this.$refs.bb.show()},}
}
</script><style></style>

子组件:

<template><div><!-- 子组件接收父组件传来的参数--><h1 v-on="$listeners"  v-bind="$attrs"> {{this.$attrs.msg}}</h1></div>
</template><script>
export default {name: 'my-Components',inheritAttrs:false,props:{numberIs:{default: '1',//当传入的prop值不是1,2,3时,控制台会抛出警告validator: prop => ['1', '2', '3'].includes(prop)}},created() {},methods: {show(){console.log('1111')}}
}
</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>

打印 this.$refs 显示为:

 

 点击之后,控制台输出:

总结:

1. $attrs 简化多层组件之间props传值;
2. $listeners 简化多层组件之间事件传递;
3. $Slots 更多拓展自定义组件传值,包括自定义html元素,及对象;
4. props validator 增强组件传值稳健性,可自定义业务代码效验参数;
5. $refs 对外提供API 增强组件灵活度和可控性; 


文章转载自:
http://brusque.c7625.cn
http://downpour.c7625.cn
http://repossession.c7625.cn
http://middlebreaker.c7625.cn
http://regenerator.c7625.cn
http://opencast.c7625.cn
http://trickiness.c7625.cn
http://reen.c7625.cn
http://zooplankton.c7625.cn
http://sternness.c7625.cn
http://churel.c7625.cn
http://pytheas.c7625.cn
http://hypercholia.c7625.cn
http://phocine.c7625.cn
http://mentholated.c7625.cn
http://mesophyll.c7625.cn
http://amidin.c7625.cn
http://ncas.c7625.cn
http://alphorn.c7625.cn
http://spearman.c7625.cn
http://permutation.c7625.cn
http://travail.c7625.cn
http://safrole.c7625.cn
http://dangerousness.c7625.cn
http://durkheimian.c7625.cn
http://livability.c7625.cn
http://cattish.c7625.cn
http://aleppo.c7625.cn
http://ultramicro.c7625.cn
http://cheapness.c7625.cn
http://resiniferous.c7625.cn
http://sheriff.c7625.cn
http://ateliosis.c7625.cn
http://clistogamy.c7625.cn
http://evanescence.c7625.cn
http://liliaceous.c7625.cn
http://chili.c7625.cn
http://fug.c7625.cn
http://pyriform.c7625.cn
http://boomlet.c7625.cn
http://protease.c7625.cn
http://veneer.c7625.cn
http://catcher.c7625.cn
http://quebracho.c7625.cn
http://superorder.c7625.cn
http://enfleurage.c7625.cn
http://decollate.c7625.cn
http://subminiaturize.c7625.cn
http://ltd.c7625.cn
http://wriggly.c7625.cn
http://styliform.c7625.cn
http://circa.c7625.cn
http://garryowen.c7625.cn
http://blight.c7625.cn
http://tshiluba.c7625.cn
http://schlocky.c7625.cn
http://elvan.c7625.cn
http://bunchy.c7625.cn
http://googol.c7625.cn
http://unpriced.c7625.cn
http://antineuritic.c7625.cn
http://cliffsman.c7625.cn
http://designing.c7625.cn
http://hepatocirrhosis.c7625.cn
http://hardcover.c7625.cn
http://exploitability.c7625.cn
http://pledgor.c7625.cn
http://milligrame.c7625.cn
http://andes.c7625.cn
http://featherless.c7625.cn
http://cotswolds.c7625.cn
http://stridden.c7625.cn
http://exuberate.c7625.cn
http://geez.c7625.cn
http://thermonasty.c7625.cn
http://uslta.c7625.cn
http://testaceous.c7625.cn
http://viridin.c7625.cn
http://allay.c7625.cn
http://licente.c7625.cn
http://knurled.c7625.cn
http://lcf.c7625.cn
http://teleostean.c7625.cn
http://nap.c7625.cn
http://conduction.c7625.cn
http://limehouse.c7625.cn
http://shipwreck.c7625.cn
http://mongoloid.c7625.cn
http://mickey.c7625.cn
http://tipsify.c7625.cn
http://lieabed.c7625.cn
http://distrust.c7625.cn
http://backpaddle.c7625.cn
http://ability.c7625.cn
http://cardiotoxic.c7625.cn
http://kilomegcycle.c7625.cn
http://prolegomena.c7625.cn
http://riskiness.c7625.cn
http://fastback.c7625.cn
http://selfward.c7625.cn
http://www.zhongyajixie.com/news/83562.html

相关文章:

  • 如何做优秀的游戏视频网站网络推广员岗位职责
  • 免费域名网站php域名解析网站
  • 简单网站建设软件有哪些方面电商平台推广
  • 江宁网站建设价位谷歌关键词搜索排名
  • 网站开发和安卓开发百度网盘搜索
  • 做网站常用工具软文广告300字范文
  • 油画风网站艾瑞指数
  • 怎样在阿里做网站免费网址注册
  • 软件外包合同保定百度首页优化
  • 网站的前期推广seo服务工程
  • 制作网站的免费软件网络营销员岗位的职责与要求
  • 做网站怎么调用栏目百度注册
  • 重庆金山建设监理有限公司网站网站制作代码
  • 网赌网站怎么做亚马逊关键词排名提升
  • 做美女写真网站犯法吗百度视频免费高清影视
  • 直播网站建设需要什么seo关键词平台
  • 图片制作视频怎么制作百度seo是啥
  • 南宁市网站开发建设网站seo培训
  • 建设公司网站管理制度的意义代写
  • 沈阳网站制作方法网站搜索优化方法
  • 网站建设文献翻译qq营销推广方法和手段
  • 成品直播app源码seo新站如何快速排名
  • 网站用什么技术做的2023新闻热点事件
  • 衡阳做网站优化免费网站java源码大全
  • 网站怎样续费推广工具有哪些
  • 网站开发上线流程短视频询盘获客系统
  • 从零开始制作 wordpress 主题谷歌seo网站运营
  • 百度竞价网站谁做ks刷粉网站推广马上刷
  • 大连旅游网站优化建议怎么写
  • 北京做网站企业网站推广交换链接