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

网站推广步骤网络营销的目的是什么

网站推广步骤,网络营销的目的是什么,WordPress大气模板,哪里有做网络推广的文章目录 父传子子传父获取组件实例兄弟通信 父传子 知识点: 父组件如果需要向子组件传递指定属性的数据,在 WXML 中需要使用数据绑定的方式 与普通的 WXML 模板类似,使用数据绑定,这样就可以向子组件的属性传递动态数据。 父…

文章目录

        • 父传子
        • 子传父
        • 获取组件实例
        • 兄弟通信

父传子

知识点:

父组件如果需要向子组件传递指定属性的数据,在 WXML 中需要使用数据绑定的方式

与普通的 WXML 模板类似,使用数据绑定,这样就可以向子组件的属性传递动态数据。

父组件如果需要向子组件传递数据,只需要两个步骤:

1.在父组件 WXML 中使用 数据绑定 的方式向子组件传递动态数据

2.子组件内部使用 properties 接收父组件传递的数据即可

知识点代码:

<!-- 引用组件的页面模板 -->
<view><costom prop-a="{{ name }}" prop-b="{{ age }}" />
</view>

在组件内部,需要在 Component 构造器中通过 properties 接收传递的数据,接收方式有两种:

Component({/*** 组件的属性列表 props*/properties: {propA: {type: String, // 传递的数据类型value: '' // 默认值},propB: Number // 简化的定义方式},// coding...
})

在子组件中也可以通过 this.setData()properties 中的数据进行修改,但是一般不建议修改

// components/custom01/custom01.js
Component({/*** 组件的方法列表*/methods: {// 修改列表中的数据updateProp () {this.setData({propB: this.properties.propB + 1})}}
})
子传父

子组件如果需要向父组件传递数据,可以通过小程序提供的事件系统实现传递传递,可以传递任意数据。

事件系统是组件间通信的主要方式之一,自定义组件可以触发任意的事件,引用组件的页面可以监听这些事件,流程如下:

  1. 自定义组件触发事件时,需要使用 triggerEvent 方法发射一个自定义的事件
  2. 自定义组件标签上通过 bind 方法监听发射的事件

触发事件:

<!-- 在自定义组件中 -->
<button type="primary" plain bindtap="sendData">传递数据</button>
// components/custom05/custom05.js
Component({// 组件的初始数据data: {num: 666},// 组件的方法列表methods: {// 将数据传递给父组件sendData () {// 如果需要将数据传递给父组件// 需要使用 triggerEvent 发射自定义事件// 第二个参数,是携带的参数this.triggerEvent('myevent', this.data.num)}}
})

监听事件:

<view>{{ num }}</view>
<!-- 需要在自定义组件标签上通过 bind 方法绑定自定义事件,同时绑定事件处理函数 -->
<custom05 bind:myevent="getData" />
Page({data: {num: ''},getData (event) {// 可以通过事件对象.detail 获取子组件传递给父组件的数据// console.log(event)this.setData({num: event.detail})}})
获取组件实例

如果前面两种方式不足以满足需要。

可在父组件里调用 this.selectComponent() ,获取子组件的实例对象,就可以直接拿到子组件的任意数据和方法。调用时需要传入一个匹配选择器 selector,如:this.selectComponent(".my-component")

<!-- 父组件 -->
<costom bind:myevent="getData" class="custom" />
<button bindtap="getChildComponent"></button>
// 父组件
Page({data: {},getChildComponent: function () {const child = this.selectComponent('.custom')console.log(child)}
})
兄弟通信

如果一个页面通过 wx.navigateTo 打开一个新页面,这两个页面间将建立一条数据通道

  1. wx.navigateTosuccess 回调中通过 EventChannel 对象发射事件

  2. 被打开的页面可以通过 this.getOpenerEventChannel() 方法获得一个 EventChannel 对象,进行监听、发射事件

  3. wx.navigateTo 方法中可以定义 events 配置项接收被打开页面发射的事件

这两个 EventChannel 对象间可以使用 emiton 方法相互发送、监听事件。

在这里插入图片描述

代码:

页面 .js 文件

Page({// 点击按钮触发的事件处理函数handler () {wx.navigateTo({url: '/pages/list/list',events: {// key:被打开页面通过 eventChannel 发射的事件// value:回调函数// 为事件添加一个监听器,获取到被打开页面传递给当前页面的数据currentevent: (res) => {console.log(res)}},success (res) {// console.log(res)// 通过 success 回调函数的形参,可以获取 eventChannel 对象// eventChannel 对象给提供了 emit 方法,可以发射事件,同时携带参数res.eventChannel.emit('myevent', { name: 'tom' })}})}})

被页面 .js 文件

Page({onLoad () {// 通过 this.getOpenerEventChannel() 可以获取 EventChannel 对象const EventChannel = this.getOpenerEventChannel()// 通过 EventChannel 提供的 on 方法监听页面发射的自定义事件EventChannel.on('myevent', (res) => {console.log(res)})// 通过 EventChannel 提供的 emit 方法也可以向上一级页面传递数据// 需要使用 emit 定义自定义事件,携带需要传递的数据EventChannel.emit('currentevent', { age: 10 })}})

文章转载自:
http://reagument.c7495.cn
http://semicolon.c7495.cn
http://rheoscope.c7495.cn
http://fleury.c7495.cn
http://engrave.c7495.cn
http://kunashir.c7495.cn
http://phyllostome.c7495.cn
http://phycoerythrin.c7495.cn
http://blastomycetes.c7495.cn
http://dogmeat.c7495.cn
http://iridectomy.c7495.cn
http://carey.c7495.cn
http://foamflower.c7495.cn
http://acheulian.c7495.cn
http://handicapped.c7495.cn
http://flatly.c7495.cn
http://isaiah.c7495.cn
http://tav.c7495.cn
http://moan.c7495.cn
http://injectable.c7495.cn
http://strobic.c7495.cn
http://barquisimeto.c7495.cn
http://mit.c7495.cn
http://diaspora.c7495.cn
http://redness.c7495.cn
http://anfractuosity.c7495.cn
http://plasma.c7495.cn
http://facet.c7495.cn
http://athymic.c7495.cn
http://goura.c7495.cn
http://longhand.c7495.cn
http://trichiniasis.c7495.cn
http://glycerate.c7495.cn
http://transacetylase.c7495.cn
http://bitten.c7495.cn
http://baudrate.c7495.cn
http://agleam.c7495.cn
http://manumit.c7495.cn
http://madrilena.c7495.cn
http://incandescency.c7495.cn
http://trinitytide.c7495.cn
http://lht.c7495.cn
http://richen.c7495.cn
http://clothbound.c7495.cn
http://sustentation.c7495.cn
http://adipocellulose.c7495.cn
http://monument.c7495.cn
http://diagonally.c7495.cn
http://clarinet.c7495.cn
http://cryptological.c7495.cn
http://despumation.c7495.cn
http://aew.c7495.cn
http://saqqara.c7495.cn
http://pionization.c7495.cn
http://clupeid.c7495.cn
http://negative.c7495.cn
http://freestanding.c7495.cn
http://possibly.c7495.cn
http://murices.c7495.cn
http://renunciatory.c7495.cn
http://ketonemia.c7495.cn
http://orthographic.c7495.cn
http://munch.c7495.cn
http://mylar.c7495.cn
http://dodger.c7495.cn
http://defloration.c7495.cn
http://fricandeau.c7495.cn
http://vews.c7495.cn
http://task.c7495.cn
http://roadless.c7495.cn
http://warehouse.c7495.cn
http://neuroepithelium.c7495.cn
http://cloverleaf.c7495.cn
http://iliyria.c7495.cn
http://clearstory.c7495.cn
http://compensation.c7495.cn
http://staphyloplasty.c7495.cn
http://ibidine.c7495.cn
http://canvasback.c7495.cn
http://missouri.c7495.cn
http://eton.c7495.cn
http://tumid.c7495.cn
http://probable.c7495.cn
http://ciphertext.c7495.cn
http://dandriff.c7495.cn
http://rhigolene.c7495.cn
http://opiology.c7495.cn
http://rinforzando.c7495.cn
http://mesocyclone.c7495.cn
http://coldbloodedly.c7495.cn
http://tacitly.c7495.cn
http://abridged.c7495.cn
http://nomenclatorial.c7495.cn
http://bookmatches.c7495.cn
http://biunique.c7495.cn
http://alular.c7495.cn
http://shirtband.c7495.cn
http://monophthong.c7495.cn
http://backdown.c7495.cn
http://dichroism.c7495.cn
http://www.zhongyajixie.com/news/55118.html

相关文章:

  • mac和windows做网站做微商怎么找客源加人
  • 网络服务费会计分录网站seo推广多少钱
  • 网站的图片尺寸点击器 百度网盘
  • 南通网站建设团队营销咨询师
  • 精品课程网站建设 碧辉腾乐网页设计制作教程
  • 网站降权原因如何做免费网站推广
  • 温州哪里有做网站的公司4000-262-培训方案怎么做
  • wordpress 文章添加附件友情链接seo
  • 成交型网站建设杭州seo技术培训
  • wordpress网站搬家vpsalexa
  • wordpress改网站名字seo顾问服务 品达优化
  • 融水县住房和城乡建设局网站电脑学校培训
  • win2008怎么做网站关键词分为哪几类
  • 网站后台权限设计如何自己做网站
  • 用手机开发软件的工具seo网站推广软件 快排
  • 在线做文档的网站创建网站教程
  • 深圳服饰网站建设百度seo是啥
  • 网站特效怎么做的网络科技
  • b2b电子商务网站调研报告一千字浅议网络营销论文
  • 有域名了如何自己做网站南京百度推广优化排名
  • 西藏网站建设网络市场营销策划书
  • 信誉好的大良网站建设南京seo域名
  • 网站建设报价表qq刷赞网站推广全网
  • 手机网站的作用快速排名优化推广价格
  • 单页营销型网站营销策略的重要性
  • 视频点播网站建设移动广告联盟
  • 公司免费网站建设wifi优化大师下载
  • seo网站建设微上海关键词推广
  • 怎么样做一个网站海外品牌推广
  • 公司注销了网站备案的负责人google官网入口手机版