我有这样的反应类..
class Questions extends React.Component {
decodestr(decstr){
var newstr = Base64.decode(decstr);
return newstr;
}
render() {
return(
<div className="questions">
{this.decodestr(this.props.cont)}
</div>
)
}
}
我正在尝试在div中显示解码内容,如下所示:
<div> <span> <b>Questions Regulatory:</b></span> <span>{source.questions_regulatory}</span> </div>
其中{source.questions_regulatory}是编码内容..如何在此打印解码内容..现在出现如下错误:ReferenceError:Base64未定义
我使用npm install Base64 --save安装了Base64。
这是我的webpack配置;
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool:"eval",
context:path.join(__dirname),
entry: [
'webpack-hot-middleware/client?reload=true',
'./src/index.jsx'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
alias: {
react: path.resolve('./node_modules/react')
},
extensions:[".js", ".jsx", ".webpack.js", ".web.js",""]
},
resolveLoader: {
root: path.join(__dirname, "node_modules")
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: [
require.resolve('babel-preset-es2015'),
require.resolve('babel-preset-react')
]
}
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
{
test: /\.(jpg|png|svg)$/,
loaders: [
'file-loader?name=[path][name].[ext]'
]
}
]
}
};
不确定如何使用此React类渲染已解码的内容。也不确定为什么我会收到推荐错误...有任何帮助表示感谢...