微信小程序父組件向子組件傳參,子組件樣式無(wú)效問(wèn)題處理
父組件代碼
引入
json
"usingComponents": {
"evaluate":"../evaluate/evaluate"
},
wxml
<evaluate id='1111'></evaluate>
子組件代碼
json文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-700444.html
{
"usingComponents": {
"van-rate": "@vant/weapp/rate/index"
},
"component": true, //必須
"options": {
"addGlobalClass": true //必須加這個(gè) 不然子組件css無(wú)效
}
}
js文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-700444.html
Component({
data: {
//基本數(shù)據(jù)
},
lifetimes: {
attached() {
//傳遞參數(shù)接受 this.xxx
console.log(this.id);
},
},
//自帶方法
pageLifetimes: {
show() {
console.log(2);
},
},
//接受類(lèi)似 vue props
properties: {
id: {
type: Number,
value: 0,
},
},
//自己自定義方法
methods: {
tabsTo(e) {
const statusId = e.currentTarget.dataset.id;
this.setData({ statusId });
},
},
});
希望此文章能幫助到你
到了這里,關(guān)于微信小程序父組件向子組件傳參,子組件樣式無(wú)效問(wèn)題處理的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!