Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

组件嵌套样式问题 #404

Closed
SzHeJason opened this issue Jul 31, 2018 · 3 comments
Closed

组件嵌套样式问题 #404

SzHeJason opened this issue Jul 31, 2018 · 3 comments

Comments

@SzHeJason
Copy link

SzHeJason commented Jul 31, 2018

问题描述
组件嵌套样式无法正常工作

复现步骤

  1. 创建父子组件
  2. 在页面上使用
  3. 父子组件样式混乱
// 父级
import Taro from '@tarojs/taro'

import { View } from '@tarojs/components'

import './index.scss'

export default class AtFlex extends Taro.Component {
  render () {
    const rootClass = ['at-flex']

    return <View className={rootClass}>{this.props.children}</View>
  }
}

// 子级
import Taro from '@tarojs/taro'

import { View } from '@tarojs/components'

import './index.scss'

export default class AtFlexItem extends Taro.Component {
  render () {
    const rootClass = ['at-flex__item']
    return <View className={rootClass}>{this.props.children}</View>
  }
}
// 父级样式
.at-flex {
  display: flex;
}

// 子级样式
.at-flex {
  @include display-flex();
}

image
image

期望行为
能与正常DOM节点样式一致

系统信息

  • 操作系统: macOS
  • Taro 版本 V1.0.0-beat-1
  • Node.js 版本 8.11.2
@zacksleo
Copy link
Contributor

zacksleo commented Aug 4, 2018

你是说父级样式不在子级中起作用? 如果是这个意思,小程序的组件就是这样的,无法与DOM一致

@SzHeJason
Copy link
Author

不是啊 是指当出现 父子级组件的时候 父级组件 影响不了子级组件的样式 比如 父级有 display:flex 子级有 flex:1 这种情况样式没有得到预期的效果

@SzHeJason
Copy link
Author

小程序本身好像就不支持这种方式 我关闭这个issue吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants