草庐IT

react-css-modules

全部标签

javascript - CSS @media 查询(和其他嵌套选择器)的正则表达式解析

我正在开发一个Node脚本,它使用正则表达式来解析CSS文件,并且它工作得很好......除了处理@media查询时。问题是由于嵌套的花括号让我很不舒服。我基本上想创建一个媒体查询中所有内容的捕获组:这是我到目前为止所获得的内容。@media[^{]+\{([^}]+)}\s*}这适用于一些简单的事情,例如:@media(max-width:868px){aside.size-toggle{display:none;}}但是不能拾取多个嵌套规则,像这样:@media(max-width:767px){#wrapper.sidebar-displayaside{left:0;transi

javascript - 在 React material-ui 上显示对话框

我正在使用material-ui的Dialogcomponent对于我的React应用程序。如何将组件设置为变量以便调用onShow()方法? 最佳答案 添加Dialog组件时,只需为其添加一个ref即可(例如ref="dialog"):dialogcontent然后您可以使用this.refs.dialog.onShow(...)从您的所有者组件代码中引用它。Dialogcomponent页面实际上在幕后使用了refs,正如你可以从它的sourcecode中看到的那样. 关于javas

javascript - 当我在 css 中使用 margin auto 属性时,如何使用 javascript 获取 margin left size

我有div与margin:auto;我只需要得到margin-left使用javascript的大小值:)//css.test{margin:auto;width:100px;height:100px;outline:1pxsolidred;}//htmlTestLiveexample 最佳答案 使用这个:1)使用jQueryvarleft=$(".test").offset().left;2)或者,第二个版本是:将您的div替换为,并使用这个js。varleft=document.getElementById("test").of

javascript - 具有多个按钮的 React 表单 - 如何选择一个来处理 onSubmit 事件?

假设我有这个HTML:Output:和这个JS:functionotherAction(e){document.getElementById('output').innerHTML='otherAction';e.preventDefault();}functionsubmit(e){document.getElementById('output').innerHTML='submit';e.preventDefault();}ReactDOM.render(OtherActionSubmit,document.getElementById('container'));其实我们不光说,

javascript - vueJS + webpack : importing fonts, CSS 和 node_modules

我开始使用Vue.js和Webpack,我对如何正确导入和引用我的字体、CSS和node_modules有一些疑问。我使用vue-cli启动了我的应用程序,结果结构如下:buildconfignode_modulessrc--assets--components--routerstatic这是我的webpack.base.conf文件:varpath=require('path')varutils=require('./utils')varconfig=require('../config')varvueLoaderConfig=require('./vue-loader.conf')

javascript - React onClick 函数参数变成 "Proxy"对象

我在我的react层次结构的顶层有一个元素数组,我想用一个带有元素值(字符串)的参数来触发一个onClick函数。然而,当我尝试打印这个值时,打印了一个“Proxy”对象:p>这是我的渲染函数中的代码:returncollapseChoices.map((choice)=>{console.log(choice)return(this.handleCollapse(choice)}>{choice});这里是handleCollapse函数:handleCollapse(mark){console.log(mark);}我确保在构造函数中绑定(bind)thisconstructor(

javascript - 如何使用 Jest 和 Enzyme 在 React 中测试表单提交?无法读取未定义的属性 'preventDefault'

我正在编写一个测试来检查如果提交的登录表单没有数据,是否会显示错误通知组件。describe('Usersignin',()=>{it('shouldfailifnocredentialsareprovided',()=>{constloginComponent=shallow();expect(loginComponent.find('.form-login').length).toBe(1);loginComponent.find('.form-login').simulate('submit');expect(loginComponent.find(Notification).l

javascript - 如何将 Javascript 变量值放入 CSS?

如何让time变量的内容显示为content我的CSS中的属性?JavaScript:functionclock(){vard=newDate();varhour=d.getHours();varmin=d.getMinutes();vartime=hour+":"+min;}CSS:.screen{position:absolute;height:75%;width:75%;background:#98E8EE;top:11.5%;left:12.5%;}.screen::after{color:#F9F5F4;font-size:40px;content:;font-family:

javascript - 在 react 中上传和读取文件

我尝试使用React上传文件并查看其内容,但它给我的是C:\fakepath\。我知道它为什么会给出fakepath,但是在React中上传和读取文件内容的正确方法是什么?handleChange:function(e){switch(e.target.name){case'myFile':constdata=newFormData();data.append('file',e.target.value);console.log(data);default:console.error('ErrorinhandleChange()');break;}}, 最佳

javascript - 我如何将 React 与 Google Places API 结合使用,以在 Google map 上显示地点标记?

我正在尝试构建与onAirbnb类似的map,您可以在其中四处拖动map时查看地点标记。我想在map上显示来自GooglePlacesAPI的“酒店”标记。使用来自GoogleMaps的以下JavaScript代码,我可以在谷歌地图上显示酒店,但我想用React来做这件事,使用react-google-maps.Placesearches/*Alwayssetthemapheightexplicitlytodefinethesizeofthediv*elementthatcontainsthemap.*/#map{height:100%;}/*Optional:Makesthesamp