"dependencies": {
"vue": "^2.4.2"
},"devDependencies": {
"webpack": "^3.4.1","webpack-dev-server": "^2.6.1"
}
"dependencies": {
"babel-core": "^6.25.0"
}
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',//值可以是字符串、数组或对象
output: {
path: path.resolve(__dirname,'./dist'),1)">Webpack结果存储
publicPath: '/dist/',1)">懵懂,懵逼,//然而“publicPath”项则被许多Webpack的插件用于在生产模式和开发模式下下更新内嵌到css、html,img文件里的url值
filename: 'build.js'
},module: {
rules: [
{
test: /\.vue$/ other vue-loader options go here
}
},{
test: /\.js$//node_modules/
},{
test: /\.(png|jpg|gif|svg)$/'[name].[ext]?[hash]'
}
}
自己加的
"style-loader!css-loader""style-loader!css-loader!sass-loader!"
}
]
},resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},devServer: {webpack-dev-server配置
historyApiFallback: true,1)">不跳转
noInfo: true实时刷新
},performance: {
hints: false
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}), webpack.optimize.UglifyJsPlugin({
sourceMap: webpack.LoaderOptionsPlugin({
minimize:
})
])
}
引用模板
import Vue from 'vue';
import Router from 'vue-router';
import indexPage from './components/header.vue'
import homePage from './views/home.vue'
import aboutPage from './views/about.vue'
Vue.use(Router)
export default Router({
routes:[
{
path:'/'
<!DOCTYPE html>
<html>
head>
meta charset="UTF-8"title></</bodydiv id="appIndex">
divscript src="./dist/build.js"script>
<!--App.vue是项目入口文件。-->
template="app"header-tabh2>{{msg}}class="nav-box">
p ="nav-list">
router-link ="nav-item" to="/">首页router-link="/about">关于prouter-view>
>
import HeaderTab from './components/header.vue;
export default {
name: appreturn {
msg: Welcome to Your Vue.js App
}
},components:{
HeaderTab
}
}
style lang="scss"
$redColor:#f00;
h2{
color:$redColor;
}
#app
text-align center; #2c3e50
margin-top 60px
h1,h2
font-weight normal
ul
list-style-type none
padding 0
li left
margin 0 10px
a #42b983}
style>
main.js这是项目的核心文件。全局的配置都在这个文件里面配置
import Vue from 'vue'
import App from './App.vue'
import router from './routes.js'
import './assets/styles/base.css'
import './assets/sass/reset.sass'//报错暂时不用sass
Vue.config.debug = true;开启错误提示
Vue({
router,el: '#appIndex' h(App)
})
h1>共同headerimg ="../assets/images/logo.png"
@import '../assets/sass/common.scss'
>
olli v-for="todo in todos">
{{ todo.text }}
libutton @click="eClick()">事件button
export indexP {
todos: [
{ text: 首页第一段文本 },{ text: 首页第二段文本首页第三段文本 }
]
}
},methods:{
eClick(){
console.log(9999);
}
}
}
scoped
olwidth200pxmargin20px auto>
$redColor:#f00;
h2{$redColor;
}
@import '../assets/sass/reset.scss'
>