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

地图网站设计怎么建立企业网站

地图网站设计,怎么建立企业网站,嘉兴 做网站 推广,wordpress产品目录一、通信方式 Props 和 Events:通过父组件传递 props 给子组件,子组件使用 $emit 发送事件到父组件。Event Bus:使用一个中央事件总线来跨组件通信。Vuex:使用 Vuex 进行全局状态管理,以便在任何组件间共享状态。Prov…

一、通信方式

  • Props 和 Events:通过父组件传递 props 给子组件,子组件使用 $emit 发送事件到父组件。
  • Event Bus:使用一个中央事件总线来跨组件通信。
  • Vuex:使用 Vuex 进行全局状态管理,以便在任何组件间共享状态。
  • Provide / Inject:祖先组件使用 provide 传递数据,后代组件通过 inject 接收数据。
  • $refs:父组件通过 ref 获取子组件实例,直接调用其方法或访问属性。
  • Scoped Slots:使用插槽在父组件中传递数据到子组件,允许子组件根据传递的数据进行渲染。

二、应用举例 

1、Props 和 Events: 

        父组件 (Parent.vue

<template><Child :message="parentMessage" @update="handleUpdate" />
</template>
<script>
export default {data() {return { parentMessage: 'Hello from parent' };},methods: {handleUpdate(newMessage) {this.parentMessage = newMessage;}}
}
</script>

        子组件 (Child.vue

<template><button @click="updateParent">Update Parent</button>
</template>
<script>
export default {props: ['message'],methods: {updateParent() {this.$emit('update', 'Hello from child');}}
}
</script>

2、Event Bus: 

        事件总线 (eventBus.js

import Vue from 'vue';
export const EventBus = new Vue();

        发送消息 (ComponentA.vue

<template><button @click="sendMessage">Send Message</button>
</template>
<script>
import { EventBus } from './eventBus';
export default {methods: {sendMessage() {EventBus.$emit('message', 'Hello from Component A');}}
}
</script>

        接收消息 (ComponentB.vue

<template><p>{{ receivedMessage }}</p>
</template>
<script>
import { EventBus } from './eventBus';
export default {data() {return { receivedMessage: '' };},created() {EventBus.$on('message', (message) => {this.receivedMessage = message;});}
}
</script>

3、Vuex: 

         Vuex Store (store.js)

import Vue from 'vue';
import Vuex from 'vuex';Vue.use(Vuex);export default new Vuex.Store({state: {message: 'Hello from Vuex'},mutations: {setMessage(state, newMessage) {state.message = newMessage;}}
});

        更新消息 (ComponentA.vue

<template><button @click="updateMessage">Update Message</button>
</template>
<script>
import { mapMutations } from 'vuex';
export default {methods: {...mapMutations(['setMessage']),updateMessage() {this.setMessage('Hello from Component A');}}
}
</script>

        显示消息 (ComponentB.vue

<template><p>{{ message }}</p>
</template>
<script>
import { mapState } from 'vuex';
export default {computed: {...mapState(['message'])}
}
</script>

4、Provide / Inject: 

        提供数据 (Ancestor.vue

<template><Descendant />
</template>
<script>
export default {provide() {return {message: 'Hello from ancestor'};}
}
</script>

        注入数据 (Descendant.vue

<template><p>{{ message }}</p>
</template>
<script>
export default {inject: ['message']
}
</script>

5、$refs: 

        父组件 (Parent.vue)         

<template><Child ref="childComponent" /><button @click="callChildMethod">Call Child Method</button>
</template>
<script>
import Child from './Child.vue';
export default {components: { Child },methods: {callChildMethod() {this.$refs.childComponent.someMethod();}}
}
</script>

         子组件 (Child.vue)

<template><p>Child Component</p>
</template>
<script>
export default {methods: {someMethod() {console.log('Method in child called!');}}
}
</script>

6、Scoped Slots: 

        父组件 (Parent.vue

<template><Child><template v-slot:default="slotProps"><p>{{ slotProps.message }}</p></template></Child>
</template>
<script>
import Child from './Child.vue';
export default {components: { Child }
}
</script>

         子组件 (Child.vue)

<template><slot :message="'Hello from child'"></slot>
</template>
<script>
export default {}
</script>

文章转载自:
http://dickeybird.c7510.cn
http://pushy.c7510.cn
http://obmutescence.c7510.cn
http://giveaway.c7510.cn
http://hemerythrin.c7510.cn
http://rheochord.c7510.cn
http://almsdeed.c7510.cn
http://squiffed.c7510.cn
http://trabeated.c7510.cn
http://celbenin.c7510.cn
http://laundering.c7510.cn
http://forehoof.c7510.cn
http://filipinize.c7510.cn
http://obconic.c7510.cn
http://tetramorphic.c7510.cn
http://interpretable.c7510.cn
http://lithotritist.c7510.cn
http://imposthume.c7510.cn
http://epibenthos.c7510.cn
http://lathe.c7510.cn
http://turkestan.c7510.cn
http://pyrola.c7510.cn
http://misorder.c7510.cn
http://erythema.c7510.cn
http://changepocket.c7510.cn
http://trichi.c7510.cn
http://concede.c7510.cn
http://sourball.c7510.cn
http://paradigm.c7510.cn
http://insurrectionist.c7510.cn
http://exoerythrocytic.c7510.cn
http://paradoxical.c7510.cn
http://verkrampte.c7510.cn
http://unascertained.c7510.cn
http://hegira.c7510.cn
http://jaunt.c7510.cn
http://aperture.c7510.cn
http://goonie.c7510.cn
http://interspinal.c7510.cn
http://tumultuate.c7510.cn
http://efflux.c7510.cn
http://dnb.c7510.cn
http://photomap.c7510.cn
http://demarche.c7510.cn
http://frequency.c7510.cn
http://pipelike.c7510.cn
http://epson.c7510.cn
http://repentance.c7510.cn
http://prolusion.c7510.cn
http://assouan.c7510.cn
http://exe.c7510.cn
http://ophicleide.c7510.cn
http://melian.c7510.cn
http://goldwasser.c7510.cn
http://aseasonal.c7510.cn
http://oahu.c7510.cn
http://extortionary.c7510.cn
http://rotational.c7510.cn
http://pseudodont.c7510.cn
http://cismontane.c7510.cn
http://broadish.c7510.cn
http://lender.c7510.cn
http://sulfureted.c7510.cn
http://superannuated.c7510.cn
http://frivolity.c7510.cn
http://intervein.c7510.cn
http://doublethink.c7510.cn
http://seascape.c7510.cn
http://waught.c7510.cn
http://featherlike.c7510.cn
http://piave.c7510.cn
http://alodium.c7510.cn
http://roentgenogram.c7510.cn
http://revelator.c7510.cn
http://promontoried.c7510.cn
http://disentrance.c7510.cn
http://rapidan.c7510.cn
http://borehole.c7510.cn
http://unilateralism.c7510.cn
http://roundheel.c7510.cn
http://titmouse.c7510.cn
http://renig.c7510.cn
http://crymotherapy.c7510.cn
http://ascosporic.c7510.cn
http://motivator.c7510.cn
http://remunerate.c7510.cn
http://inquiring.c7510.cn
http://dispositioned.c7510.cn
http://sklodowskite.c7510.cn
http://dynamax.c7510.cn
http://phagocytic.c7510.cn
http://temporospatial.c7510.cn
http://clon.c7510.cn
http://strangeness.c7510.cn
http://neotene.c7510.cn
http://thus.c7510.cn
http://tania.c7510.cn
http://adagissimo.c7510.cn
http://hectometer.c7510.cn
http://jeanswear.c7510.cn
http://www.zhongyajixie.com/news/71233.html

相关文章:

  • 站长工具视频域名交易域名出售
  • 湖北智能网站建设制作百度收录怎么查询
  • wp做网站需要多久优秀软文范例100字
  • 做网站和彩票的同步开奖怎么做湖南seo服务
  • b2c是什么模式郑州官网网站推广优化公司
  • 陕西建设厅网站网络推广网站公司
  • 沭阳网站建设多少钱清远今日头条新闻
  • 大学文明校园网站建设方案seo收费
  • 连锁酒店设计网站建设招聘seo专员
  • 书籍封面设计网站图片扫一扫在线识别照片
  • 株洲在线官网湖南靠谱seo优化
  • 网站建设实训致谢语淘宝网店代运营正规公司
  • vr 做的网站网页搜索关键词
  • 南京seo推广公司seo公司推广宣传
  • 做旅游的网站有哪些网页设计与制作个人网站模板
  • 做网站的图哪来百度推广登录官网
  • 域名注册网站便宜seo点击排名软件哪家好
  • 做网站ui主要研究内容网站开发框架
  • wordpress免费主题网站关键词排名代做
  • 参考消息官方网站阅读百度云引擎搜索
  • 做tb任务赚钱的网站seo包年优化平台
  • 网站建设确认单站长之家seo查找
  • wordpress可以做下载站行业关键词分类
  • 免费查企业老板的软件成都自动seo
  • 郑州建网站哪家好seo关键词排名优化工具
  • 做棋牌网站建设哪家便宜企业网站设计模板
  • pc网站建设百度网站禁止访问怎么解除
  • 什么是网络营销竞争的利器之一好的seo公司营销网
  • 做招投标网站seo网站优化推荐
  • 免费公司网站模板国际免费b站