vue.js - .vue文件里面用import就报错
本文介绍了vue.js - .vue文件里面用import就报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
<template>
<div id="app">
<!-- <img class="logo" src="./assets/logo.png"> -->
<hello></hello>
<p>
Welcome to your Vue.js app!
</p>
<p>
To get a better understanding of how this boilerplate works, check out
<a href="http://vuejs-templates.github.io/webpack" target="_blank">its documentation</a>.
It is also recommended to go through the docs for
<a href="http://webpack.github.io/" target="_blank">Webpack</a> and
<a href="http://vuejs.github.io/vue-loader/" target="_blank">vue-loader</a>.
If you have any issues with the setup, please file an issue at this boilerplate's
<a href="https://github.com/vuejs-templates/webpack" target="_blank">repository</a>.
</p>
<p>
You may also want to checkout
<a href="https://github.com/vuejs/vue-router/" target="_blank">vue-router</a> for routing and
<a href="https://github.com/vuejs/vuex/" target="_blank">vuex</a> for state management.
</p>
</div>
</template>
<script>
import Hello from './components/Hello'
export default {
components: {
Hello
}
}
</script>
<style>
html {
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
#app {
color: #2c3e50;
margin-top: -100px;
max-width: 600px;
font-family: Source Sans Pro, Helvetica, sans-serif;
text-align: center;
}
#app a {
color: #42b983;
text-decoration: none;
}
.logo {
width: 100px;
height: 100px
}
</style>
module.exports = {
devtool: 'eval-source-map', //配置生成Source Maps,选择合适的选项
entry: __dirname + "/src/main.js", //唯一入口文件
output: {
path: __dirname, // 打包后文件存放的地方
filename: "bundle.js" //打包后输出文件的文件名
},
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: {presets:['es2015']}},
{
test: /\.vue$/,
loader: 'vue'
}
]
},
resolve: {
alias: {
vue: 'vue/dist/vue.js'
}
},
devServer: {
// contentBase: "./",//本地服务器所加载的页面所在的目录
colors: true,//终端中输出结果为彩色
historyApiFallback: true,//不跳转
inline: true//实时刷新
}
}
解决方案
babel: {
presets: ['es2015']
},
这篇关于vue.js - .vue文件里面用import就报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文