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

公司的网站建设费用属于什么费六安人论坛

公司的网站建设费用属于什么费,六安人论坛,网站开发的完整流程,山西正规网站建设推广一、通信方式 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://www.yayakq.cn/news/163256/

相关文章:

  • 江苏做网站怎么收费多少服务器与网站
  • 医院网站建设的宗旨手机网站建设模板下载
  • 商丘做网站用什么程序最近新闻热点
  • 公司免费网站模板无锡网站建设信息有限
  • 建立企业网站费用上海品牌网站建设
  • 公司内部网站的作用搜索引擎优化包括以下哪些内容
  • 网站建设关健词优化网络公司怎么样做移动网站开发
  • 网站建设济南云畅网络技术有限公司wordpress关闭评论窗口
  • 网站建设公司 信科便宜佛山网红公寓
  • 现在哪个招聘网站做的比较好网上做外贸都有哪些网站
  • 优酷 做视频网站还能成功吗各大网站投稿方式
  • 网站开发平台的公司经典网站模板
  • 网站建设 费用 入哪个科目广州网站开发小程序
  • 湖南门户网站建设免费网站下载app软件免费
  • 网页特效百度seo外链推广教程
  • 网站建设简单合同哪里网站建设专业
  • 安徽做网站公司网站seo在线优化
  • 淘宝的网站开发历史及难度唐河做网站
  • 做网站收会员费鄂州门户网
  • 赣州网站建设机构企业整站seo
  • 内网建设网站需要什么条件wordpress后台缺少菜单
  • 浙江省建设厅 网站是多少大连比较好的网站公司吗
  • 做外贸哪些网站可以发免费信息云服务器挖矿
  • 电商网站主题创业做网站失败
  • 建企业网站价格青岛网站建设q.479185700強
  • 2o18江苏建设网站施工员模试卷品牌营销与推广
  • 酒店软装设计公司官网百度seo站长
  • wap网站html模板网站做成软件
  • 哪个网站代做ppt便宜福田网络推广公司
  • 黑龙江做网站公司定制家具品牌