我只能看到实际的应用程序/public.
配置webpack.config.js如下:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./app/js/App.js'
],
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js',
publicPath: 'http://localhost:8080'
},
module: {
loaders: [
{
test: /\.js$/,
loaders: ['react-hot', 'babel-loader'],
exclude: /node_modules/
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};
Run Code Online (Sandbox Code Playgroud)
项目层次结构是:
应用
node_modules
上市
CSS
IMG
bundle.js
的index.html
的package.json
webpack.config.js
如何修改以确保该http://localhost:8080/条目适用于应用程序本身?
假设您有一个按钮来替换同一区域、同一页面内的段落。
您可以通过设置innerText或使每个开关textContent每次都淡入吗?
我现在使用keyframes将其不透明度从 0 更改为 1,但它仅适用于页面加载后的第一段。之后,每当我用 替换文本时innerText,效果根本不显示。
排队等候的所有文本都是用 JavaScript 硬编码的,而不是用 HTML 编码的——如果它做出改变的话。
我只是发布组件的代码:
class AddPostForm extends React.Component {
createPost(event) {
event.preventDefault();
let post = {
title : this.refs.title.value,
name : this.refs.name.value,
desc : this.refs.desc.value,
image : this.refs.image.value
}
this.props.addPost(post);
this.refs.postForm.reset();
}
render() {
return (
<div className="callout secondary form-area">
<h5>Add a Post to the React Blog</h5>
<form className="post-edit" ref="postForm" onSubmit={this.createPost}>
<label>Post Title
<input type="text" ref="title" placeholder="Post Title" required/>
</label>
<label>Author Name
<input type="text" ref="name" placeholder="Full Name required" required/>
</label>
<label>Post Body
<textarea
ref="desc"
placeholder="Write your post here" required/>
</label>
<label>Image URL - …Run Code Online (Sandbox Code Playgroud) 使用下面的代码,我只能border-image为其底部生成线性渐变.如何修改代码以使其成为顶级代码?
div {
/* gradient shining border */
border-style: solid;
border-width: 3px;
-webkit-border-image: -webkit-linear-gradient(
left,
rgba(0,0,0,1) 1%,
rgba(0,255,255,1) 50%,
rgba(0,0,0,1) 100%
) 0 0 100% 0/0 0 3px 0 stretch;
-moz-border-image: -moz-linear-gradient(
left,
rgba(0,0,0,1) 1%,
rgba(0,255,255,1) 50%,
rgba(0,0,0,1) 100%
) 0 0 100% 0/0 0 3px 0 stretch;
-o-border-image: -o-linear-gradient(
left,
rgba(0,0,0,1) 1%,
rgba(0,255,255,1) 50%,
rgba(0,0,0,1) 100%
) 0 0 100% 0/0 0 3px 0 stretch;
border-image: linear-gradient(
to left,
rgba(0,0,0,1) 1%,
rgba(0,255,255,1) 50%,
rgba(0,0,0,1) 100%
) 0 …Run Code Online (Sandbox Code Playgroud) 我正在用 React 钩子重写一个 CRUD 表。下面的自定义钩子useDataApi用于获取表的数据,观察 url 更改 - 因此它会在 params 更改时触发。但我还需要在删除和编辑后获取最新的数据。我怎样才能做到这一点?
const useDataApi = (initialUrl, initialData) => {
const [url, setUrl] = useState(initialUrl)
const [state, dispatch] = useReducer(dataFetchReducer, { data: initialData, loading: true })
useEffect(() => {
const fetchData = async () => {
dispatch({ type: 'FETCH_INIT' })
const result = await instance.get(url)
dispatch({ type: 'FETCH_SUCCESS', payload: result.data })
}
fetchData()
}, [url])
const doFetch = url => {
setUrl(url)
}
return { ...state, doFetch }
}
Run Code Online (Sandbox Code Playgroud)
由于 …
reactjs ×3
css ×2
javascript ×2
webpack ×2
border ×1
fadein ×1
html ×1
node.js ×1
react-hooks ×1
reactjs-flux ×1