我想在此基础上的关键字存在于一个数组来过滤一些内容,但不知道该怎么做,尝试使用includes,indexof和search功能,但它并没有我的情况下工作.
我的第一次尝试:
const filters = ['movie', 'food']
contents
.filter( content => filters.includes(content.name))
Run Code Online (Sandbox Code Playgroud)
问题是这content.name是一个包含多个单词的字符串,例如"看你最喜欢的电影","投票给你最喜欢的食物"等等,我想检查一个字符串是否包含过滤器变量中的一个关键字.目前includes()返回,false因为它试图匹配确切的字符串.
webpack -p --progress --colors我已经能够在 webpack 开发服务器上使用样式组件,没有任何问题,但在构建生产项目或运行项目时,样式没有添加webpack -d --progress --colors --watch
生产中添加的唯一样式是空样式
<style data-styled="" data-styled-version="4.4.1"></style>
Run Code Online (Sandbox Code Playgroud)
在 webpack.config.js 中,我有以下针对开发和生产运行的规则:
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
}
},
]
Run Code Online (Sandbox Code Playgroud)
},
插件,注意 debug 用于判断是否是生产版本
plugins: debug ? [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'template.html')
})
] : [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
},
}),
new CleanWebpackPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new UglifyJsPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'template.html')
}) …Run Code Online (Sandbox Code Playgroud)