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
[bug report] layout component. When modifying the jitter value passed to the El row component, the component does not update the column interval value correctly #1441
Comments
Translation of this issue: Element Plus version1.0.2-beta.31 OS/Browsers versionMicrosoft edge version 88.0.705.56 (official build) (64 bit) Vue version3.0.5 Reproduction Linkhttps://jsfiddle.net/3gpamjny/6/ Steps to reproduce
What is Expected?
a. The root cause of this bug is const gutter = inject('ElRow', 0) if (gutter) { paddingLeft: gutter / 2 'px', } return {} The value of gutter is non responsive, so the value of style is always the value evaluated for the first time. That's why there is this bug. row.ts file const status = reactive({ gutter: props.gutter }) // ... status.gutter = props.gutter //Here, the response value is assigned to trigger the execution of the effect wrapper function he collects props.tag , class: [ props.justify !== 'start' ? props.type === 'flex' ? 'el-row--flex' : '', style: style.value , slots.default? .(), } col.ts file Const status = inject ('status', {gutter: 0}) / / inject the responsive data provided by the parent component Const {gutter} = status / / Yes status.gutter Evaluate and collect the computed effect wrapper function return { paddingRight: gutter / 2 'px', } }) }
What is actually happening?
|
Thanks, there is indeed a problem here, if you are interested in this, you can fork this repo, and open a pr after making changes, we will review and merge it. |
@Ryan2128 of course, I'm very interested. I try my best to submit a pr. |
Thanks. |
Element Plus version
1.0.2-beta.31
OS/Browsers version
Microsoft Edge 版本 88.0.705.56 (官方内部版本) (64 位)
Vue version
3.0.5
Reproduction Link
https://jsfiddle.net/3gpamjny/6/
Steps to reproduce
2.点击修改‘修改gutter值’按钮
3.el-row根元素正确更新,el-col的根元素未更新
What is Expected?
1.期望el-col根元素的样式padding-left和padding-right的值正确更新。
2.element-ui layout组件是正常的,因为col组件是通过递归获取父元素的gutter,而父元素的gutter是响应式值,对col组件的render watch实例进行了依赖收集,所以gutter值变化后,col组件能正常更新。其实element-ui layout组件也可以使用inject和provide来优化。
3.关于element-plus layout组件这个bug的修改,我下面提供下我的思路,希望可以参考下
a.这个bug的根本原因是
gutter值是非响应式值,导致style的值永远都是第一次求值完的值,所以才有这个bug。
b.解决方案一:
row.ts文件
setup(props, { slots }) {
}
col.ts 文件
setup(props, { slots }) {
}
这么改造完,就能解决这个问题。原理:父组件提供响应式值,子组件的计算属性依赖了该响应式值,从而当响应式发生变化后,计算属性下次求值才能得到最新值。
4.第一次提issue,如果格式不对,请删除。还有我想为element-plus尽一份力,不知道咋搞,头疼
What is actually happening?
1.实际上只有el-row的margin-left和margin-right的值正确更新了
The text was updated successfully, but these errors were encountered: