需求:父組件樣式影響子組件,但子組件樣式不影響父組件。
子組件中,定義如下:
Component({
options: {
styleIsolation: 'isolated',
// 或者
addGlobalClass: true,
}
})
或者在頁面的 json 文件中配置如下信息:
{
"styleIsolation": "isolated"
}
需求:父組件樣式影響子組件,但子組件樣式不影響父組件。
子組件中,定義如下:
Component({
options: {
styleIsolation: 'isolated',
// 或者
addGlobalClass: true,
}
})
或者在頁面的 json 文件中配置如下信息:
{
"styleIsolation": "isolated"
}