草庐IT

config_ref_index

全部标签

javascript - 使用 webpack-dev-server 时,html-webpack-plugin 不会将 js 文件注入(inject) index.html

这是我的webpack配置:varpath=require('path');varwebpack=require('webpack')varHtmlWebpackPlugin=require('html-webpack-plugin')varfs=require('fs'),buildPath='./dist/';varfolder_exists=fs.existsSync(buildPath);if(folder_exists==true){require('shelljs/global')rm('-rf','dist')};module.exports={entry:'./src/

javascript - 处理 z-index 图层上的点击事件

我正在构建的map应用程序中有2个z-index图层。单击图层放大时出现问题。单击处理程序位于底层z-index图层上,我不希望它在单击覆盖图层中的控件时触发。我遇到的问题是,无论如何都会引发事件,但是当单击顶层上的某些内容时,事件的originalTarget属性不是底层中的图像。无论如何要改变这个? 最佳答案 这叫做事件冒泡,你可以通过event.stopPropagation()方法(IE中的event.cancelBubble())来控制它。您还可以通过从元素上的onwhatever属性调用的处理程序返回true/false

javascript - 如何正确安装 eslint-config-airbnb? `UNMET PEER DEPENDENCY`

➜beslintgit:(master)✗eslint-vv3.15.0➜beslintgit:(master)✗npminstall-geslint-config-airbnbeslint-plugin-jsx-a11yeslint-plugin-importeslint-plugin-react/Users/next/.nvm/versions/node/v7.5.0/lib├──UNMETPEERDEPENDENCYeslint@^3.15.0├─┬eslint-config-airbnb@14.1.0│└──UNMETPEERDEPENDENCYeslint@^3.15.0├─

javascript - 如何使用 React refs 来聚焦 Redux 表单字段?

我正在尝试使用Reactrefs在安装时聚焦Redux-FormField。当我在componentDidMount中尝试this.refs.title.getRenderedComponent().focus()时,会抛出一条错误消息:edit_fund.js:77未捕获类型错误:无法读取未定义的属性“getRenderedComponent”当我控制台记录this.refs时,它主要是一个空对象,有时将“title”标识为ref,但它不可靠。我是否错误地使用了refs?我的代码在下面供引用。componentDidMount=()=>{this.refs.title.getRend

javascript - lodash map get index key 得到了意外的 token

import{map}from'lodash';render(){return({map(new_applicants,(obj,index)=>{index})})}这段代码有什么问题?obj是被迭代的单个对象数组,index是键。我正在使用lodash。错误在控制台中看起来像这样。{map(new_applicants,(obj,index)=>|^ 最佳答案 问题是{...}语法被用于对象初始值设定项;你在JSX的之外做这件事。该语法仅在JSX部分内有效,例如{map(...)}此外,render必须返回一个组件(或null)

javascript - react : How to access refs in this. props.children

我想调用一个子组件的函数。是否有可能在React中从this.props.children获取引用。varComponentSection=React.createClass({componentDidMount:function(){//Howtoaccessrefsinthis.props.children?this.refs.inner.refs.specificPanel.resize();},render:function(){return({this.props.children});}});varPanel=React.createClass({resize:functi

javascript - 通过将 refs 设置为变量来 react 查找 DOM 节点?

我正在动态创建多个文本输入(使用动态创建的引用)以及我想用输入更新的文本。我试图通过将ref设置为变量并使用React.findDOMNode(this.refs.Variable).value查找DOM节点来获取输入的值我收到“无法读取null的属性‘值’”错误。我怎样才能做到这一点?函数是这样的:resetUnit:function(e){varrefID=e.target.id;varID=refID.split("-")[0];varValue=React.findDOMNode(this.refs.refID).value;NodesCollection.update({_i

javascript - highcharts 工具提示 z-index

我正在尝试让highcharts工具提示有一个zIndex使用useHTML将其定位在另一个HTML元素上。请参阅此fiddle:http://jsfiddle.net/sDu8V/我希望工具提示越过粉红色方框,而不是下方。我错过了什么? 最佳答案 可能的解决方案:http://jsfiddle.net/sDu8V/1/所需的CSS:.highcharts-container{position:inherit!important;}.highcharts-tooltip{z-index:9998;}感谢@Piotr,更新了4.1.x

javascript - 通过 gulp 从 index.html 中删除脚本

我在我们的应用程序中使用gulp,我们在Gulpfile.js中有2个流程,一个用于生产,第二个用于开发,但我不想保留2个index.html文件,例如index.html和index.dev。html,我想要一个index.html文件,但是对于生产构建,我有一些不需要的脚本,例如.问题是:如何通过Gulp从html中删除某些内容? 最佳答案 您可以使用专用于此特定目的的gulp-html-replace插件:https://www.npmjs.org/package/gulp-html-replace

javascript - 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react'

在尝试使用Webpack4和Babel7构建React应用程序时,我遇到了以下错误。ERRORin./src/index.jsModulebuildfailed(from./node_modules/babel-loader/lib/index.js):Error:Cannotfindmodule'babel-preset-react'from'/Users/me/Desktop/reflask'-Ifyouwanttoresolve"react",use"module:react"-Didyoumean"@babel/react"?atFunction.module.exports[