[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
(found in <Root>)
This problem is how to cause it, looking for a long time to find a way to deal with it, the Internet has not found a good solution. Later, I looked at official documents and found a similar answer.
What does that mean? Run-time builds do not include a template compiler, so there is no support for the template option, only the Render option, but even with run-time builds, templates can still be written to a single-file component because the template of a single-file component is precompiled into the Render function at build time. A run-time build is 30% lighter than a stand-alone build, only 17.14 Kb min+gzip size. The above paragraph is explained in the official API. That is, if we want to use template, we cannot directly use vue after NPM install on the client side. Resolve: {alias: {‘vue’: ‘vue/dist/vue. Js’}}
Here is my finished code webpack.config.babel.js
/**
* Created by lenovo on 2017/5/8.
*/
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
const config = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'dist')
},
module: {
loaders:[
{
test: /\.js$/,
loader: 'babel'
},
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.html',
title: 'hello App'
})
],
resolve: {
alias: {
'vue': 'vue/dist/vue.js'
}
}
}
export default config;Copy the code
package.json
{" name ":" demo ", "version" : "1.0.0", "main" : "index. Js", "scripts" : {" test ", "echo \" Error: No test specified\" && exit 1"}, "dependencies": {"vue": "^2.3.2"}, "devDependencies": {"babel-core": "^ 6.3.26", "Babel - loader" : "^ 6.2.0", "Babel - preset - es2015" : "^ 6.24.1", "HTML - webpack - plugin" : "^ 2.28.0", "webpack" : "^ 1.12.9 vue -", "loader" : "^ 12.0.3", "vue - the template - the compiler" : "^" 2.3.2}}Copy the code
I don’t know if there are any friends who have encountered such a problem, if you do not know how to solve it, I think this article will help you.