1.我使用了hbs模板,页面出现了test但是没有出现数字列表,控制台下是有ul列表的,而且title也对,就是不出现列表,为什么?
main.js文件如下
import { map } from 'lodash';
import template from './numberlist.hbs';
let numbers = map([1,2,3,4,5,6], n => n*n);
var testHtml=template({numbers})
document.getElementById("app-container").innerHTML=template({numbers});
document.getElementById("app-container").innerHTML="<div>test</div>";
console.log(template({numbers}));
console.log(typeof template({numbers}))
-
webpack.config.js配置如下
const path = require('path');
var HtmlWebpackPlugin=require("html-webpack-plugin")
module.exports = {
entry: [
'babel-polyfill',
'./src/main.js'
],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js'
},
module:{
rules:[
{
test:/.jsx?$/,
loader:'babel-loader',
exclude: /node_modules/,
options:{
plugins: ['transform-runtime'],
presets: ['es2015']
}
},
{
test: /.hbs$/,
loader: 'handlebars-loader'
}
]
},
plugins:[
new HtmlWebpackPlugin({
title: 'Intro to webpack ???',
template: 'src/index.html'
})
]
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…