分配的可变道具的首选大小无法正常工作。
P粉349222772
P粉349222772 2024-03-30 09:42:29
[CSS3讨论组]

我想为编辑器制作一个可拖动的分割面板。其行为主要类似于CodeSandbox的Console面板:

  1. 当我们点击Console时,面板展开,箭头变为ArrowDown用于关闭。
  2. 面板的边框是可拖动的。
  3. 当我们在展开的面板上点击 Console 时,面板关闭,箭头变为 ArrowUp 进行展开。

我有以下代码(https://codesandbox.io/s/reset-forked-ydhy97?file=/src/App.js:0-927),作者:https://github.com/johnwalley/allotment 。问题是 preferredSize 属性在 this.state.toExpand 之后没有更改。

有人知道为什么这不起作用吗?

import React from "react";
import { Allotment } from "allotment";
import "allotment/dist/style.css";
import styles from "./App.module.css";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      toExpand: true
    };
  }

  render() {
    return (
      
Main Area
{ this.setState({ toExpand: !this.state.toExpand }); }} > Console   {this.state.toExpand ? "ArrowUp" : "ArrowDown"}
); } }

P粉349222772
P粉349222772

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号