微信小程序父组件调用子组件里面的函数方法及传参。

news/2024/7/20 1:13:16 标签: 微信小程序, 小程序

第一步:给我们子组件加上id标识

这里封装的是时间选择器

  <v-dateTimePicker id="page" bind:showing="onConfirm"  bind:canceling="onCancel"
     wx:if="{{isShowpopup}}"/>

第二步:直接通过this.selectComponent("#page")调用方法

在这里插入图片描述

 // 父组件调用子组件中的方法
        this.selectComponent("#page").showPop('isShowpopup')

第三步:子组件里面声明这个方法

  // 出生日期
        showPop(data) {
            this.setData({
                isShowpopup: data
            })
        },

http://www.niftyadmin.cn/n/843258.html

相关文章

Vant组件中的DatetimePicker 时间选择的坑

参考原文&#xff1a; https://blog.csdn.net/u013040434/article/details/116697574

微信小程序 vant 封装DatetimePicker时间选择器

效果&#xff1a; 1.在components文件下新建dateTimePicker文件 在index.wxml文件中编写&#xff1a; <view class"container" bindtap"showPop"><van-popup show"{{ isShowpopup }}" bind:close"onClose"position"…

小程序小程序中使用echarts图表显示模糊

解决方法&#xff1a;初始化函数加入dpr参数&#xff0c;完美解决 function initChart(canvas, width, height,dpr) {const chart echarts.init(canvas, null, {width: width,height: height,devicePixelRatio: dpr});canvas.setChart(chart); }

element ui 表格根据后端返回数据 按创建时间 倒序 排序,

默认排序 代码&#xff1a; <el-tableref"table"v-loading"crud.loading":header-cell-style"{ color: #FFF, background: #333 }":cell-style"{ color: #FFF, background: #333 }":data"crud.data"style"width:…

vue 项目中使用websocket

1. 在utils下新建websocket.js文件 // import { showInfoMsg, showErrorMsg } from /utils/popInfo import ElementUI from element-ui; function initWebSocket(e) {console.log(e)const wsUri WS_API "/webSocket/" e;this.socket new WebSocket(wsUri)//这里…

vue刷新页面的时候,跳转到别的网页

开发的时候&#xff0c;偶然发现有页面刷新跳转到别的页面&#xff0c;查找发现是name属性设置重了。开始都配置name: ‘料仓’&#xff0c;导致ordinarySilo页面刷新的时候&#xff0c;跳到SMD_XLC页面。 错误代码&#xff1a; 修改后代码&#xff1a;

element-ui 报错Cannot read property ‘setCheckedKeys‘ of undefined“

报错是因为dom还没有加载完&#xff0c;就已经赋值了&#xff0c;所以才会报错的 我使用的tree是写在dialog中的 &#xff0c;如果弹窗不出现的话&#xff0c;dom也是没有加载的状态&#xff0c;所以要把弹窗出现写在前面&#xff0c;解决方案写在后面&#xff0c;才是万全之策…

Vue中的样式绑定(class和style)

动态绑定class、绑定style 对象方法 -最简单的绑定 注&#xff1a;&#xff08;这里的active加不加单引号都可以&#xff0c;以下也一样都能渲染 :class"{ active: isActive }".判断是否绑定一个active :class"{active:isActive-1}" 或者 :class&quo…