微信小程序父组件向子组件传参,子组件样式无效问题处理

微信小程序父组件向子组件传参,子组件样式无效问题处理

父组件代码

引入

json

c 复制代码
  "usingComponents": {
    "evaluate":"../evaluate/evaluate"
  },

wxml

html 复制代码
  <evaluate id='1111'></evaluate>

子组件代码

json

c 复制代码
{
  "usingComponents": {
    "van-rate": "@vant/weapp/rate/index"
  },
  "component": true, //必须
  "options": { 
    "addGlobalClass": true  //必须加这个 不然子组件css无效
  }
}

js

javascript 复制代码
Component({
  data: {
	//基本数据
  },
  lifetimes: {
    attached() {
    //传递参数接受 this.xxx
      console.log(this.id);
    },
  },
  //自带方法
  pageLifetimes: {
    show() {
      console.log(2);
    },
  },
  //接受类似 vue props
  properties: {
    id: {
      type: Number,
      value: 0,
    },
  },
  //自己自定义方法
  methods: {
    tabsTo(e) {
      const statusId = e.currentTarget.dataset.id;
      this.setData({ statusId });
    },
  },
});

希望此文章能帮助到你

相关推荐
2501_9160088936 分钟前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
微擎应用市场37 分钟前
简单拼车小程序系统:实现出行与物流资源的高效精准匹配
小程序
甜到心里的蛋糕2 小时前
如何用企业微信实现让微信收到通知实时通知
服务器·python·微信小程序·fastapi
2501_916008892 小时前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview
2601_963870202 小时前
基于springboot的综合网上购物商场系统
微信小程序·小程序·课程设计
2601_9638699513 小时前
力序健身房管理系统
微信小程序·小程序
一 乐16 小时前
二手交易平台|基于springboot + vue二手交易平台(源码+数据库+文档)
java·数据库·vue.js·spring boot·小程序
拖孩21 小时前
给小程序加「一键发公众号贴图」,我把 wx.shareToOfficialAccount 的三个坑趟了一遍
前端·后端·微信小程序
微擎应用市场21 小时前
鲸飞云 PMS 系统 —— 现代化酒店运营的智能管理解决方案
小程序
疯狂小猫咪1 天前
教务管理系统课时消课模块设计思路
大数据·小程序