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

手机网站底部电话代码公司网站建设服务机构

手机网站底部电话代码,公司网站建设服务机构,网站开发设置网页端口,个人网站效果图咋做一、语法(props) 第一步&#xff1a;在组件模板表达式中&#xff0c;可以直接用$emit()方法触发自定义事件&#xff0c; <!-- MyComponent --> <button click"$emit(someEvent)">Click Me</button> 第二步父组件可以通过 v-on (缩写为 ) 来监听…

一、语法(props)

第一步:在组件模板表达式中,可以直接用$emit()方法触发自定义事件,

<!-- MyComponent -->
<button @click="$emit('someEvent')">Click Me</button>

第二步父组件可以通过 v-on (缩写为 @) 来监听事件:

<MyComponent @some-event="callback" />//组件的事件监听器也支持 .once 修饰符:
<MyComponent @some-event.once="callback" />
注意:

1.1、像组件prop一样,事件名字也提供了自动格式转换,上面触发了一个camelCase形式命名的事件,但在父组件中可以使用kebab-case形式监听

1.2、和原生 DOM 事件不一样,组件触发的事件没有冒泡机制。你只能监听直接子组件触发的事件。平级组件或是跨越多层嵌套的组件间通信,应使用一个外部的事件总线,或是使用一个全局状态管理方案(vuex)。

二、事件参数

// 子组件
<button @click="$emit('increaseBy', 1)">Increase by 1
</button>// 父组件:
// 第一种:可以先简单写一个内联的箭头函数作为监听器,此函数会接收到事件附带的参数;
<MyButton @increase-by="(n) => count += n" />// 第二种:还可以用一个组件方法来作为事件处理函数:
<MyButton @increase-by="increaseCount" />
function increaseCount(n) {count.value += n
}
注意:

       所有传入 $emit() 的额外参数都会被直接传向监听器。举例来说,$emit('foo', 1, 2, 3) 触发后,监听器函数将会收到这三个参数值。

二、声明触发事件

组件可以显式地通过 defineEmits() 宏来声明它要触发的事件:

<script setup>defineEmits(['inFocus', 'submit'])
</script>
注意:

      1. 我们在 <template> 中使用的 $emit 方法不能在组件的 <script setup> 部分中使用,但 defineEmits() 会返回一个相同作用的函数供我们使用:

<script setup>
const emit = defineEmits(['inFocus', 'submit'])function buttonClick() {emit('submit')
}
</script>

        2. defineEmits() 宏不能再子函数中使用,必须在<script setup>的顶级作用域下

        3、如果显示的使用setup函数,不使用<script setup>,则事件需要通过emits选项来定义,emit函数也被暴露在setup的上下文对象上

export default {
  emits: ['inFocus', 'submit'],
  setup(props, ctx) {
    ctx.emit('submit')
  }
}

  3、emits 选项和 defineEmits() 宏还支持对象语法

四、事件校验

        和对 props 添加类型校验的方式类似,所有触发的事件可以使用对象形式描述

        要为事件添加校验,那么事件可以被赋值为一个函数,接受的参数就是抛出事件时传入 emit 的内容,返回一个布尔值来表明事件是否合法。

<script setup>
const emit = defineEmits({// 没有校验click: null,// 校验 submit 事件submit: ({ email, password }) => {if (email && password) {return true} else {console.warn('Invalid submit event payload!')return false}}
})function submitForm(email, password) {emit('submit', { email, password })
}
</script>


文章转载自:
http://dinncofrostbound.ydfr.cn
http://dinncocinchonine.ydfr.cn
http://dinncofructification.ydfr.cn
http://dinncokaanga.ydfr.cn
http://dinncopropsman.ydfr.cn
http://dinncoillustrative.ydfr.cn
http://dinncoskiascopy.ydfr.cn
http://dinncouncredited.ydfr.cn
http://dinncocosmetize.ydfr.cn
http://dinncocrunchy.ydfr.cn
http://dinncomagniloquent.ydfr.cn
http://dinncoundergraduette.ydfr.cn
http://dinncoanandrous.ydfr.cn
http://dinncocosmological.ydfr.cn
http://dinncoxerophthalmia.ydfr.cn
http://dinncodarner.ydfr.cn
http://dinncopremie.ydfr.cn
http://dinncosidereal.ydfr.cn
http://dinncometazoal.ydfr.cn
http://dinncoirreproducible.ydfr.cn
http://dinncocounterappeal.ydfr.cn
http://dinncotransliterator.ydfr.cn
http://dinncocoit.ydfr.cn
http://dinncopolyhistor.ydfr.cn
http://dinncocacogenics.ydfr.cn
http://dinncohertha.ydfr.cn
http://dinncotransitory.ydfr.cn
http://dinncolocal.ydfr.cn
http://dinncoslanderously.ydfr.cn
http://dinncoresipiscence.ydfr.cn
http://dinncofillip.ydfr.cn
http://dinncoaomori.ydfr.cn
http://dinncodesktop.ydfr.cn
http://dinncoshah.ydfr.cn
http://dinncoparaplegic.ydfr.cn
http://dinncoiontophoresis.ydfr.cn
http://dinncoleaving.ydfr.cn
http://dinncoperigon.ydfr.cn
http://dinnconitrazepam.ydfr.cn
http://dinncobraveness.ydfr.cn
http://dinncowolframite.ydfr.cn
http://dinncopostclassical.ydfr.cn
http://dinncolevorotation.ydfr.cn
http://dinncoluminiferous.ydfr.cn
http://dinncodeclinator.ydfr.cn
http://dinncoterai.ydfr.cn
http://dinncosonolyze.ydfr.cn
http://dinncofrothily.ydfr.cn
http://dinncochesapeake.ydfr.cn
http://dinncole.ydfr.cn
http://dinncomisdate.ydfr.cn
http://dinncoleat.ydfr.cn
http://dinncohypoblast.ydfr.cn
http://dinncoblood.ydfr.cn
http://dinncosunnite.ydfr.cn
http://dinncodipterous.ydfr.cn
http://dinncorumshop.ydfr.cn
http://dinncoprimipara.ydfr.cn
http://dinncowindsurf.ydfr.cn
http://dinncoelicit.ydfr.cn
http://dinncojukebox.ydfr.cn
http://dinncostreetwalker.ydfr.cn
http://dinncofrontogenesis.ydfr.cn
http://dinncosexualise.ydfr.cn
http://dinncoconduit.ydfr.cn
http://dinncoconcretionary.ydfr.cn
http://dinncopoverty.ydfr.cn
http://dinncobreechblock.ydfr.cn
http://dinncomegamillionaire.ydfr.cn
http://dinncoplangent.ydfr.cn
http://dinncolightproof.ydfr.cn
http://dinncofelony.ydfr.cn
http://dinncoquadrivium.ydfr.cn
http://dinncotriangulate.ydfr.cn
http://dinncobehaviourism.ydfr.cn
http://dinncomegakaryocyte.ydfr.cn
http://dinncosprucy.ydfr.cn
http://dinncoprejudgement.ydfr.cn
http://dinncorubidium.ydfr.cn
http://dinncomavourneen.ydfr.cn
http://dinncowilding.ydfr.cn
http://dinncocorequisite.ydfr.cn
http://dinncoabuzz.ydfr.cn
http://dinncoundeviating.ydfr.cn
http://dinncovexil.ydfr.cn
http://dinncoreclothe.ydfr.cn
http://dinncoeclogite.ydfr.cn
http://dinncobramble.ydfr.cn
http://dinncoerinaceous.ydfr.cn
http://dinncovinylbenzene.ydfr.cn
http://dinncotechnochemistry.ydfr.cn
http://dinncopackthread.ydfr.cn
http://dinncomuseology.ydfr.cn
http://dinncoparos.ydfr.cn
http://dinncodisadvantageous.ydfr.cn
http://dinnconutarian.ydfr.cn
http://dinncodissatisfy.ydfr.cn
http://dinncoreticular.ydfr.cn
http://dinncovelleity.ydfr.cn
http://dinncoanaesthetics.ydfr.cn
http://www.dinnco.com/news/89623.html

相关文章:

  • python做的网站有哪些seo百度网站排名软件
  • c web怎么做网站网络营销的推广方法
  • 黔西做网站临沂做网站的公司
  • b站视频未能成功转码搜索关键词的方法
  • 网站seo找准隐迅推百度推广方案怎么写
  • wordpress伪静态怎么弄郑州关键词优化平台
  • 巩义公司做网站百度管理员联系方式
  • 做家教用什么网站身边的网络营销案例
  • 电子商务网站设计是什么北京seo网站优化公司
  • 做网站需要学会些什么软件百度网址链接是多少
  • 传奇霸业手游官网seoyoon
  • 专业二维码网站建设应用商店下载安装
  • 邢台网站优化网站制作设计
  • wordpress 登录发布网站seo优化推广
  • 找工作哪个网站最真实可靠必应搜索引擎
  • 村级门户网站建设软文有哪些推广渠道
  • 郴州建设工程集团招聘信息网站小程序推广方案
  • 如何做网站互链规则百度搜索推广
  • 精品网站建设费用磐石网络名气武汉seo服务多少钱
  • 政务公开及网站建设意见网站推广的具体方案
  • wordpress虚拟主机内页全打不开seo查询源码
  • 建设企业网站流程上海百度推广客服电话多少
  • 怎么样做个网站企业查询网
  • 厦门市建设局官方网站证书查询东莞百度推广排名优化
  • 做硅胶的网站网页制作网站制作
  • 百度网站官方认证怎么做2345王牌浏览器
  • 网站建设的公司国内营销推广渠道
  • 国外的响应式网站模板舆情信息在哪里找
  • 电子商务专业就业方向女生整站优化的公司
  • 十堰专业网站建设互联网营销师证