我正在使用 React,尝试将 SVG 转换为 jsx,一切看起来都很好,但是我所有的 svgs 都有一个启用背景属性
style="enable-background:new 0 0 473.806 473.806;"
Run Code Online (Sandbox Code Playgroud)
我在转换为当前使用的 JSX 时遇到问题
style={{enableBackground:'new 0 0 387.2 387.2'}}
Run Code Online (Sandbox Code Playgroud)
这不起作用,我只想使用 img 标签,但是我想在悬停时更改 SVG 的颜色。
更新:这是 SVG
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="35px" height="35px" viewBox="0 0 35 35" style="enable-background:new 0 0 35 35;" xml:space="preserve">
<g>
<path d="M25.302,0H9.698c-1.3,0-2.364,1.063-2.364,2.364v30.271C7.334,33.936,8.398,35,9.698,35h15.604
c1.3,0,2.364-1.062,2.364-2.364V2.364C27.666,1.063,26.602,0,25.302,0z M15.004,1.704h4.992c0.158,0,0.286,0.128,0.286,0.287
c0,0.158-0.128,0.286-0.286,0.286h-4.992c-0.158,0-0.286-0.128-0.286-0.286C14.718,1.832,14.846,1.704,15.004,1.704z M17.5,33.818
c-0.653,0-1.182-0.529-1.182-1.183s0.529-1.182,1.182-1.182s1.182,0.528,1.182,1.182S18.153,33.818,17.5,33.818z M26.021,30.625 …Run Code Online (Sandbox Code Playgroud) 我在这方面遇到了很多麻烦,我尝试了各种方法。我想在单击开始按钮后每秒调用一个函数,然后在单击停止按钮后暂停它。我不断出现我无法解释的奇怪行为。我怎样才能在没有课程的情况下做出反应?
我有 triid 的东西:
const simulation = () => {
if (!running) {
console.log('hit');
return
} else {
// console.log(grid);
console.log('hey');
setTimeout(simulation, 1000)
}
}
Run Code Online (Sandbox Code Playgroud)
和
enter setInterval(() => {
let newGrid = [...grid]
for (let i = 0; i < numRow; i++) {
for (let k = 0; k < numCol; k++) {
let n = 0;
}
}
console.log(grid);
}, 5000)
Run Code Online (Sandbox Code Playgroud)
我已经尝试了更多,在某些情况下,它会更新状态,我应该添加到它,但在我重置状态后没有更新它。我如何调用一个函数来每隔一秒运行一次更新的状态值*请注意,我想要运行的函数将更新状态
使用样式组件创建变体的最佳方法是什么?这就是我目前正在做的事情。
const ButtonStyle = styled.button`
padding:8px 20px;
border:none;
outline:none;
font-weight:${props => props.theme.font.headerFontWeight};
font-size:${props => props.theme.font.headerFontSize};
display:block;
&:hover{
cursor:pointer;
}
${({ variant }) =>
variant == 'header' && css`
background-color:${props => props.theme.colors.lightblue};
color:${({ theme }) => theme.colors.white};
&:active{
background-color:${props => props.theme.colors.blue}
}
`
}
${({ variant }) =>
variant == 'white' && css`
background-color:white;
color:${({ theme }) => theme.colors.lightblue};
&:active{
color:${props => props.theme.colors.blue}
}
`
}
`;
Run Code Online (Sandbox Code Playgroud)
我无法判断这是否是标准的做事方式。我还一直在使用其他组件作为基础来创建其他组件,同时更改一些内容
例如
const InnerDiv = styled(otherComponent)`
position: unset;
background-color: red;
overflow-x: hidden;
display: flex; …Run Code Online (Sandbox Code Playgroud) 我使用 todoists Rest api 来跟踪我自己的数据,但它似乎只允许您获取活动任务?
我正在查看过滤器并认为它们可能对我有帮助,但没有这方面的文档。
我试图获取某一天完成的所有任务,可以这样做吗?
在宣布放弃 mongodb 之后,目前正在迁移到 postgres 的过程中,刚刚注意到 ID 只是数字并且自动递增。
我努力了:
有人知道怎么做吗?我非常不希望我的帖子的 ID 是一个自动递增的数字。
是否有一个 docker 命令可用于清除所有内容?如果正在运行,请停止所有容器,删除所有图像,删除所有卷......等等。
我决定尝试使用 workbox,但我看到的所有指南都讨论了与 React 制作的 Service Worker 集成。
但是当我安装 CRA 时,我不再获得为我定制的 Service Worker。我需要做什么才能在这里集成工作箱?
这是我当前的代码:
应用程序.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import swDev from './swDev'
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
swDev()
Run Code Online (Sandbox Code Playgroud)
swDev.js
export default function swDev(){
let swURL = `${process.env.PUBLIC_URL}/sw.js`;
if('serviceWorker' in navigator){
navigator.serviceWorker.register(swURL).then(res => {
console.log('Service worker has been registered');
}).catch(err => console.log('Service worker was not registered'))
}
}
Run Code Online (Sandbox Code Playgroud)
那么这就是公共文件中的 Service Worker
const cacheVersion = 'v1'
self.addEventListener('install', ()=>{
console.log('Service worker has been …Run Code Online (Sandbox Code Playgroud) reactjs ×4
javascript ×3
api ×1
bookshelf.js ×1
css ×1
docker ×1
jsx ×1
next.js ×1
postgresql ×1
strapi ×1
svg ×1
todoist ×1
workbox ×1