我正在尝试将一个favicon添加到我使用webpack创建的基于React的网站上.添加一个favicon是一个彻头彻尾的噩梦,我尝试了许多解决方案无济于事.推荐给我的最新解决方案名为'favicons-webpack-plugin',可在此处找到:https://github.com/jantimon/favicons-webpack-plugin.
如果有人能告诉我我做错了什么,我们将非常感谢您的协助.
运行'npm run start'时出现以下错误
这是我的目录结构:
这是我的webpack.config.js文件:
const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const TARGET = process.env.npm_lifecycle_event;
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
var favicons = require('favicons'),
source = 'my-logo.png', // Source image(s). `string`, `buffer` or array of `{ size: filepath }`
configuration = {
appName: null, // Your application's name. `string`
appDescription: null, // Your …Run Code Online (Sandbox Code Playgroud) 我有一个范围问题.我可以在构造函数中调用console.log this.props.routeParams.key.但是当在构造函数之外,在filterList函数中,我得到错误"未捕获的TypeError:无法读取未定义的属性'道具'".我的范围问题是什么?为什么它可以从构造函数中读取,而不是从filterList函数中读取?
我正在使用React Router + Flux + React.
import AltContainer from 'alt-container';
import React from 'react';
import { Link } from 'react-router';
import Blogger from './Blogger'
import List from './List'
const rootURL = 'https://incandescent-fire-6143.firebaseio.com/';
import BlogStore from '../stores/BlogStore'
import BlogActions from '../actions/BlogActions';
export default class BlogShow extends React.Component {
constructor(props) {
super(props);
{console.log(this.props.routeParams.key)}
}
filterList(key) {
if (this.props.routeParams.key===key){
return Blogstore.state.blog
}
}
render() {
{Object.keys(BlogStore.state.blog).map(this.filterList)}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Flux + React Router + Firebase创建一个基本博客.我无法尝试获取单个博客文章进行渲染.当我点击指向单个帖子的链接时,我会尝试从所有帖子列表中过滤掉所有其他帖子,并仅显示我的firebase数据库中的一个帖子.
我尝试通过将firebase条目的键与url params匹配来完成此操作if (this.props.routeParams.key===key).我真的不知道为了实现这一点我必须做些什么.欢迎任何建议.
下面是Blogger.jsx,我允许用户创建博客帖子的页面,然后在博客文章下方,我显示所有博客帖子的标题列表.
import AltContainer from 'alt-container';
import React from 'react';
import { Link } from 'react-router';
import List from './List.jsx'
import Firebase from 'firebase'
import BlogStore from '../stores/BlogStore'
import BlogActions from '../actions/BlogActions';
const rootURL = 'https://incandescent-fire-6143.firebaseio.com/';
export default class Blogger extends React.Component {
constructor(props) {
super(props);
BlogStore.getState();
BlogStore.mountFirebase();
{console.log(this.props.location.query)}
};
componentDidMount() {
BlogStore.listen((state) => {
this.setState(state)
})
this.firebaseRef = new Firebase(rootURL + 'items/');
}
componentWillMount() {
BlogStore.unlisten((state) => {
this.setState(state) …Run Code Online (Sandbox Code Playgroud)