小编DGo*_*mez的帖子

具有背景参数的故事书的问题

我正在进行一个带有故事书的项目,我希望我的故事能够更改背景或放置背景,因为我只需要不同颜色的背景,但我不能像文档中所述那样放置背景:

https://storybook.js.org/docs/react/essentials/backgrounds

export default {
  title: 'Button',
  parameters: {
    backgrounds: {
      default: 'twitter',
      values: [
        { name: 'twitter', value: '#00aced' },
        { name: 'facebook', value: '#3b5998' },
      ],
    },
  },
};
Run Code Online (Sandbox Code Playgroud)

我的代码是这样的:

export default {
  title: "Atoms/Example",
  component,
  parameters: {
    backgrounds: {
      default: "black",
      values: [
        { name: "black", value: "#000000" },
        { name: "white", value: "#ffffff" }
      ]
    }
  },
  argTypes: {
    is: {
      control: {
        type: "select",
        options: [25, 33, 50, 75, 100]
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但我的代码根本不起作用,从文档中看到一切都是正确的。 …

javascript reactjs storybook

8
推荐指数
1
解决办法
4867
查看次数

添加边框半径条形图 d3

我需要向图表的条形添加边框,我知道有一个插件可以添加它,并且我已经看到在同一平台中提出的其他问题,但我无法将它们添加到我的条形中,我需要帮助

window.addEventListener("load", (event) => {
  // set the dimensions and margins of the graph
  var margin = { top: 10, right: 30, bottom: 20, left: 50 },
    width = 1500 - margin.left - margin.right,
    height = 350 - margin.top - margin.bottom;

  // append the svg object to the body of the page
  var svg = d3
    .select("#my_chart")
    .append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
    .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + …
Run Code Online (Sandbox Code Playgroud)

html javascript bar-chart d3.js

3
推荐指数
1
解决办法
4513
查看次数

添加多图预览并删除React

我有一个代码,我只上传 1 张图像并显示它,但我需要上传最多 5 张图像并能够删除它们,我不知道如何上传更多图像并能够显示它们在 img 标签中

这将是我的代码,我只能上传一张图像并显示它

import React, { useState } from "react";
    import "./styles.css";
    
    const SingleImageUploadComponent = () => {
      const [file, setFile] = useState(null);
    
      function uploadSingleFile(e) {
        setFile(URL.createObjectURL(e.target.files[0]));
        console.log("file", file);
      }
    
      function upload(e) {
        e.preventDefault();
        console.log(file);
      }
    
      return (
        <form>
          <div className="form-group preview">
            {file && <img src={file} alt="" />}
          </div>
    
          <div className="form-group">
            <input
              type="file"
              className="form-control"
              onChange={uploadSingleFile}
            />
          </div>
          <button
            type="button"
            className="btn btn-primary btn-block"
            onClick={upload}
          >
            Upload
          </button>
        </form>
      );
    };
    
    export default SingleImageUploadComponent;
Run Code Online (Sandbox Code Playgroud)

正如我之前提到的,我需要上传最多 5 张图像并在 …

javascript image input reactjs

0
推荐指数
1
解决办法
7238
查看次数

标签 统计

javascript ×3

reactjs ×2

bar-chart ×1

d3.js ×1

html ×1

image ×1

input ×1

storybook ×1