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

网站建设综合实训pptseo需要培训才能找到工作吗

网站建设综合实训ppt,seo需要培训才能找到工作吗,大连甘井子区很落后吗,天津做网站报价全局事件总线(GlobalEventBus) 一种可以在任意组件通信的方式,本质上就是一个对象,它必须满足以下条件 所有的组件对象都必须能看见他这个对象必须能够使用$ on $ emit $ off方法取绑定、触发和解绑事件 使用步骤 定义全局事件总线 //创建VUE new V…

全局事件总线(GlobalEventBus)

一种可以在任意组件通信的方式,本质上就是一个对象,它必须满足以下条件

  1. 所有的组件对象都必须能看见他
  2. 这个对象必须能够使用$ on $ emit $ off方法取绑定、触发和解绑事件

使用步骤

  1. 定义全局事件总线
//创建VUE
new Vue({el:'#app',render:h=> h(App),beforeCreate(){Vue.prototype.$bus=this //安装全局事件总线},})
  1. 使用事件总线
    a.接收数据:A组件想接收数据,则在A组件中给$bus 绑定自定义事件,事件的回调留在A组件自身
export default{methods(){demo(data){...}}...mounted(){this.$bus.$on('xxx',this.demo)}
}

b.提供数据:this.$bus.$emit(''xxx,data)
3. 最好在beforeDestroy钩子中,用**$off()**去解绑当前组件所用到的事件。

src/main.js

//引入vue
import Vue from 'vue'
//引入APP.vue
import App from './App.vue'//关闭Vue的生产提示
Vue.config.productionTip=false//创建VUE
new Vue({el:'#app',render:h=> h(App),beforeCreate(){Vue.prototype.$bus=this //安装全局事件总线},})

src/App.vue

<template><div class="app"><h1>{{msg}}</h1><School></School><Student></Student></div>
</template><script>import Student from './components/Student'import School from './components/School'export default {name:'App',components:{School,Student},data() {return {msg:'你好啊!'}}}
</script><style scoped>.app{background-color: gray;padding: 5px;}
</style>

src/compoents/School.vue

<template><div class="school"><h2>学校名称:{{name}}</h2><h2>学校地址:{{address}}</h2></div>
</template><script>export default {name:'School',data() {return {name:'尚硅谷',address:'北京',}},mounted() {// console.log('School',this)this.$bus.$on('hello',(data)=>{console.log('我是School组件,收到了数据',data)})},beforeDestroy() {this.$bus.$off('hello')},}
</script><style scoped>.school{background-color: skyblue;padding: 5px;}
</style>

src/compoents/Student.vue

<template><div class="student"><h2>学生姓名:{{name}}</h2><h2>学生性别:{{sex}}</h2><button @click="sendStudentName">把学生名给School组件</button></div>
</template><script>export default {name:'Student',data() {return {name:'张三',sex:'男'}},mounted() {// console.log('Student',this.x)},methods: {sendStudentName(){this.$bus.$emit('hello',this.name)}},}
</script><style  scoped>.student{background-color: pink;padding: 5px;margin-top: 30px;}
</style>

在这里插入图片描述

http://www.yidumall.com/news/82019.html

相关文章:

  • wordpress从入门深圳优化公司哪家好
  • 效果图哪个网站好正规的微信推广平台
  • wordpress文件发送邮件seo中文意思
  • 天津市建设与管理网站微信小程序开发文档
  • 做淘宝客网站哪个好用网络优化
  • 地方门户网站开发方案广东网站关键词排名
  • 做网站的排名现在有哪些培训学校
  • 作风建设主题活动 网站seo培训学院
  • 沧县网站制作软文500字范文
  • 网站建设策划实训总结网络促销
  • 深圳做棋牌网站建设哪家便宜网络营销课程
  • 做网站准备材料网站恶意点击软件
  • 开源企业网站源码google浏览器官方下载
  • 装修案例标题怎么写刷seo关键词排名软件
  • 企业展厅设计公司收费情况热狗seo顾问
  • 做一个web项目多少钱seo快速排名上首页
  • 深圳总部企业名单南昌seo快速排名
  • 商城网站建设多少钱站长友情链接平台
  • 做第三方网站注意什么意思营销型网站内容
  • 黄石网站建设教程宁波免费seo排名优化
  • 静态网站建设的技术运用高明公司搜索seo
  • 网站开发一个多少钱关键词搜索量排名
  • 类似闲鱼网站怎么做网络营销专业毕业论文
  • 高清网站推广免费下载公司怎么做网站推广
  • 沈阳人流哪个医院好安全企业seo顾问公司
  • 企业网站推广17苏州网站建设公司
  • 不用花生壳做网站服务器今天重大国际新闻
  • 微信网站怎么做知名品牌营销案例100例
  • asp网站后台不能编辑怎么申请网站详细步骤
  • 文化馆建设网站安卓优化大师最新版