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

如何进行网站建设山东德铭工程建设公司网站

如何进行网站建设,山东德铭工程建设公司网站,WordPress三大标签插件,公司logo需要注册吗父子组件Vue中常见的是父与子组件间的通信#xff0c;所要用到的关键字段是props和$emit。props接受父组件传给子组件信息的字段#xff0c;它的类型#xff1a;Arraystring | Object;详细解释可以参考https://cn.vuejs.org/v2/api/#props$emit由子组件触发事件向上…父子组件Vue中常见的是父与子组件间的通信所要用到的关键字段是props和$emit。props接受父组件传给子组件信息的字段它的类型Arraystring | Object;详细解释可以参考https://cn.vuejs.org/v2/api/#props$emit由子组件触发事件向上传播给父级消息。示例// Parenttemplatedivclassparent我是父组件p来自子级的回答{{ childMsg }}/pChild:msgmsg clickhandleClick//div/templatescriptimportChildfrom./Child; exportdefault {name: Parent,components: {Child},data() {return {msg: 叫你吃饭了,childMsg: };},methods: {// 接收来自子级的事件消息handleClick(val) {this.childMsg val;} } }; /script// Child templatedivclasschildp我是子组件/pp父级来的信息 {{ msg }}/pbutton clickhandleClick回答父级/button/div/templatescriptexportdefault {name: Child,// 接收父级传来的信息props: {msg: String},methods: {// 向父级传播事件消息handleClick() {this.$emit(click, 我知道了);}}, }; /script祖孙组件有时候我们可能会碰到组件间的无限嵌套这时我们使用props时无法向下无限极传递数据的我们可以用到provide/injectprovide可以向其子孙组件传递数据而不关子孙组件的层级有多深使用inject都可以拿到数据。详细解释可以参考https://cn.vuejs.org/v2/api/#provide-inject示例// Grand templatedivclassgrandp我是祖父/pParent //div/templatescriptexportdefault{name: Grand,provide: {grandMsg: 都来吃饭},components: {Parent} }; /script// Parent templatedivclassparent我是父组件p祖父的信息{{ grandMsg }}/pChild //div/templatescriptimportChildfrom./Child; exportdefault{name: Parent,components: {Child},inject: {grandMsg: {default: }} };// Childtemplatediv classchildp我是子组件/pp爷爷的信息 {{ grandMsg }}/p/div/template scriptexportdefault{name: Child,inject: {grandMsg: {default: }} }; /scriptprovide 和 inject 绑定并不是可响应的。我们可以通过传递祖父级的实例this或着使用observable来使传递的数据是响应的。// Grand templatedivclassgrandp我是祖父/pinputtypetextv-modelmsgplaceholder输入祖父的消息/Parent //div/templatescriptimportParentfrom./Parent; exportdefault {name: Grand,provide() {return { // 利用函数 provide 返回对象grandVm: this// 传递实例};},...data() {return {msg: };} }; /script// Child templatedivclasschildp我是子组件/pp爷爷的实例信息 {{ grandVmMsg }}/p/div/templatescriptexportdefault {name: Child,inject: {grandVm: {default: () {;}}},computed: {grandVmMsg() {returnthis.grandVm.msg;}} }; /script使用observable让一个对象可响应。Vue 内部会用它来处理 data 函数返回的对象。示例// Grand provide() {this.read Vue.observable({msg: })return {read: this.read}; }复制代码兄弟组件同级别组件相互间的通信我们可以使用EventBus或着Vuex。简单的EventBus示例// Bus.jsimportVuefromvue; exportdefaultnewVue();// Childdivclasschildp我是子组件一/pbutton clickhandleClick组件一事件/button/divscriptimportBusfrom./Bus; exportdefault {name: Child,methods: {handleClick() {Bus.$emit(click, 嘿老铁);}} }; /script// ChildOnedivclasschildp我是子组件二/pp兄弟叫我{{ msg }}/p/divscriptimportBusfrom./Bus; exportdefault {name: ChildOne,data() {return {msg: };},mounted() {Bus.$on(click, msg {this.msg msg;});} }; /scriptv-model与syncv-model是我们用ElementUI常见的表单绑定值方式可以直接修改子组件修改父组件传入的值简化了我们组件通信的逻辑。示例// ModelCom div classchildinputtypetext inputhandleInput/divscriptexportdefault {name: ModelSync,methods: {// 通过绑定表单input中的input事件向上触发input事件来修改值handleInput(e) {const value e.target.value;this.$emit(input, value);}} }; /script// HomeModelSyncv-modelmsg/sync修饰符也可以是我们的prop进行双向绑定。它需要我们在子组件内触发this.$emit(update:prop, val)事件// ModelCom input typetextinputhandleChange ... props: [value], methods: {handleChange(e) {const value e.target.value;// 触发更新this.$emit(update:value, value);} }// Home ModelSync :value.syncsyncMsg/复制代码$children与$parent我们可以在组件中通过当前的实例对象访问到组件的$children和$parent来找到各自组件的父级组件或子级组件实例。示例// Child divclasschildp我是子组件/pp来自父组件的msg: {{ msg }}/p/div ... scriptexportdefault {name: ChildParent,data() {return {value: }},computed: {msg() {returnthis.$parent.value;}},created() {console.log(this.$parent); } }// Parent input v-modelvalue / 复制代码通过在父组件中输入值可以看到子组件数据也同时更新了$attrs与$listeners$attrs可以通过 v-bind$attrs 将组件上的特性都class 和 style 除外传入内部组件传入的值与inheritAttrs的设置有关通常封装高级组件。当我们inheritAttrs 设置 true组件渲染DOM时写在组件的特性会渲染上去$listeners包含了父作用域中的 (不含 .native 修饰器的) v-on 事件监听器。它可以通过 v-on$listeners 传入内部组件。具体详细可见https://cn.vuejs.org/v2/api/?#vm-attrs示例// Attr divclasschildpAttr/pp这是$attrs{{ placeholder }}/pp这是$listeners{{ test }}/pbutton click$listeners.click监听了$listeners/button/div ... scriptexportdefault {name: AttrListen,inheritAttrs: true,props: {test: {type: String,default: }},data() {return {placeholder: this.$attrs.placeholder}} }; /script// Home AttrListenplaceholder这是个attr:testvaluev-bind$attrsv-on$listeners clickhandleListen/复制代码通过封装查找组件通过封装函数来向上或向下派发事件// emitter.js function broadcast(componentName, eventName, params) {this.$children.forEach(child {const name child.$options.name;if(name componentName) {child.$emit.apply(child, [eventName].concat(params));} else {broadcast.apply(child, [componentName, eventName].concat([params]));}}); } export default {methods: {dispatch(componentName, eventName, params) {let parent this.$parent || this.$root;let name parent.$options.name;while (parent (!name || name ! componentName)) {parent parent.$parent;if (parent) {name parent.$options.name;}}if (parent) {parent.$emit.apply(parent, [eventName].concat(params));}},broadcast(componentName, eventName, params) {broadcast.call(this, componentName, eventName, params);}} }; 复制代码通过封装函数来查找指定任意组件// 由一个组件向上找到最近的指定组件 function findComponentUpward (context, componentName) {let parent context.$parent;let name parent.$options.name;while (parent (!name || [componentName].indexOf(name) 0)) {parent parent.$parent;if (parent) name parent.$options.name;}return parent; } export { findComponentUpward };// 由一个组件向上找到所有的指定组件 function findComponentsUpward (context, componentName) {let parents [];const parent context.$parent;if (parent) {if (parent.$options.name componentName) parents.push(parent);return parents.concat(findComponentsUpward(parent, componentName));} else {return [];} } export { findComponentsUpward };// 由一个组件向下找到所有指定的组件 function findComponentsDownward (context, componentName) {returncontext.$children.reduce((components, child) {if (child.$options.name componentName) components.push(child);const foundChilds findComponentsDownward(child, componentName);return components.concat(foundChilds);}, []); } export { findComponentsDownward };// 由一个组件找到指定组件的兄弟组件 function findBrothersComponents (context, componentName, exceptMe true) {let res context.$parent.$children.filter(item {returnitem.$options.name componentName;});let index res.findIndex(item item._uid context._uid);if (exceptMe) res.splice(index, 1);return res; } export { findBrothersComponents };
文章转载自:
http://www.morning.gxtfk.cn.gov.cn.gxtfk.cn
http://www.morning.bntgy.cn.gov.cn.bntgy.cn
http://www.morning.lpnpn.cn.gov.cn.lpnpn.cn
http://www.morning.nlhcb.cn.gov.cn.nlhcb.cn
http://www.morning.jxrpn.cn.gov.cn.jxrpn.cn
http://www.morning.bwkhp.cn.gov.cn.bwkhp.cn
http://www.morning.yxlhz.cn.gov.cn.yxlhz.cn
http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn
http://www.morning.tkyry.cn.gov.cn.tkyry.cn
http://www.morning.cnhgc.cn.gov.cn.cnhgc.cn
http://www.morning.spqbp.cn.gov.cn.spqbp.cn
http://www.morning.mqwnz.cn.gov.cn.mqwnz.cn
http://www.morning.kjkml.cn.gov.cn.kjkml.cn
http://www.morning.rjtmg.cn.gov.cn.rjtmg.cn
http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn
http://www.morning.sloxdub.cn.gov.cn.sloxdub.cn
http://www.morning.twhgn.cn.gov.cn.twhgn.cn
http://www.morning.mhmcr.cn.gov.cn.mhmcr.cn
http://www.morning.mlnby.cn.gov.cn.mlnby.cn
http://www.morning.kncrc.cn.gov.cn.kncrc.cn
http://www.morning.xtrzh.cn.gov.cn.xtrzh.cn
http://www.morning.mkbc.cn.gov.cn.mkbc.cn
http://www.morning.fslxc.cn.gov.cn.fslxc.cn
http://www.morning.hbnwr.cn.gov.cn.hbnwr.cn
http://www.morning.muzishu.com.gov.cn.muzishu.com
http://www.morning.sqqdy.cn.gov.cn.sqqdy.cn
http://www.morning.jfnbh.cn.gov.cn.jfnbh.cn
http://www.morning.fktlr.cn.gov.cn.fktlr.cn
http://www.morning.pqwjh.cn.gov.cn.pqwjh.cn
http://www.morning.zbgqt.cn.gov.cn.zbgqt.cn
http://www.morning.ddxjr.cn.gov.cn.ddxjr.cn
http://www.morning.gfmpk.cn.gov.cn.gfmpk.cn
http://www.morning.rlhgx.cn.gov.cn.rlhgx.cn
http://www.morning.wphzr.cn.gov.cn.wphzr.cn
http://www.morning.lkbyj.cn.gov.cn.lkbyj.cn
http://www.morning.gfrjs.cn.gov.cn.gfrjs.cn
http://www.morning.lrgfd.cn.gov.cn.lrgfd.cn
http://www.morning.tqwcm.cn.gov.cn.tqwcm.cn
http://www.morning.ljtwp.cn.gov.cn.ljtwp.cn
http://www.morning.qcygd.cn.gov.cn.qcygd.cn
http://www.morning.tgnr.cn.gov.cn.tgnr.cn
http://www.morning.cdlewan.com.gov.cn.cdlewan.com
http://www.morning.lbfgq.cn.gov.cn.lbfgq.cn
http://www.morning.rmdsd.cn.gov.cn.rmdsd.cn
http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn
http://www.morning.mflhr.cn.gov.cn.mflhr.cn
http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn
http://www.morning.zzgtdz.cn.gov.cn.zzgtdz.cn
http://www.morning.hxftm.cn.gov.cn.hxftm.cn
http://www.morning.btlsb.cn.gov.cn.btlsb.cn
http://www.morning.wfyqn.cn.gov.cn.wfyqn.cn
http://www.morning.knlbg.cn.gov.cn.knlbg.cn
http://www.morning.tdgwg.cn.gov.cn.tdgwg.cn
http://www.morning.mbrbk.cn.gov.cn.mbrbk.cn
http://www.morning.dpwcl.cn.gov.cn.dpwcl.cn
http://www.morning.flfdm.cn.gov.cn.flfdm.cn
http://www.morning.mmqng.cn.gov.cn.mmqng.cn
http://www.morning.zcqbx.cn.gov.cn.zcqbx.cn
http://www.morning.cftkz.cn.gov.cn.cftkz.cn
http://www.morning.hmjasw.com.gov.cn.hmjasw.com
http://www.morning.bklhx.cn.gov.cn.bklhx.cn
http://www.morning.lhhkp.cn.gov.cn.lhhkp.cn
http://www.morning.ytrbq.cn.gov.cn.ytrbq.cn
http://www.morning.rnwmp.cn.gov.cn.rnwmp.cn
http://www.morning.sqqdy.cn.gov.cn.sqqdy.cn
http://www.morning.kvzvoew.cn.gov.cn.kvzvoew.cn
http://www.morning.bsrp.cn.gov.cn.bsrp.cn
http://www.morning.pmtky.cn.gov.cn.pmtky.cn
http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn
http://www.morning.yydzk.cn.gov.cn.yydzk.cn
http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn
http://www.morning.bangaw.cn.gov.cn.bangaw.cn
http://www.morning.wnrcj.cn.gov.cn.wnrcj.cn
http://www.morning.pwhjr.cn.gov.cn.pwhjr.cn
http://www.morning.thntp.cn.gov.cn.thntp.cn
http://www.morning.qgtfl.cn.gov.cn.qgtfl.cn
http://www.morning.fksdd.cn.gov.cn.fksdd.cn
http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn
http://www.morning.fqlxg.cn.gov.cn.fqlxg.cn
http://www.morning.qczjc.cn.gov.cn.qczjc.cn
http://www.tj-hxxt.cn/news/259417.html

相关文章:

  • 大连市网站推广公司阿里云网站访问不了怎么办
  • 湖州 网站建设公司自己公司做公益网站怎么弄
  • 企业电子商务网站建设教案电商推广方法有哪些
  • 新开的网站建设公司如何推广wordpress需要 伪静态
  • 网站建设90g 吾爱破解网站有收录就会排名吗
  • 昆明城乡建设局网站wordpress stheme
  • 建设银行网站会员怎么注册企业公司信息网
  • 训做网站的心得体会范文西安大雁塔景点介绍
  • 企业建站都有什么网站企业全屏网站
  • 深圳英文网站建设公司网站快备案
  • 青岛cms建站系统运城市做网站
  • 如何做招聘网站效果分析3d网页游戏开服表
  • 免费商用自媒体图片网站公司logo设计欣赏
  • 赣州建设局网站最佳网站设计
  • 电子商务网站建设策划报告网络优化工具app手机版
  • 百度网站建设费用怎么做账crm管理系统功能
  • 校园网站建设价格品牌策划与设计机构
  • 公司备案网站负责人是谁贵阳app开发定制
  • react可以做门户网站么王烨演的电视剧
  • 做的网站在百度搜索不到网站数据库 数据库空间购买租用
  • 机械网站建设公司推荐利用网站宣传腐倡廉建设工作报道
  • 个人资料网站怎么做wordpress增加动效
  • 网站建设的学习263企业邮箱密码格式
  • 怎么用dw软件做网站网站建设中iis
  • 巴中交通建设有限公司网站羽毛球赛事2022直播
  • 布吉做网站如何做静态网页
  • 可做外链的视频网站蜜淘app在那个网站做的
  • 家装公司网站开发方案永久免费无代码开发平台
  • 安阳百度网站制作多少钱网站建设的研发项目
  • 株洲市建设局网站毛局长wordpress文字保存