import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
router/index.js作用解释
import Vue from 'vue'
//导入路由
import Router from 'vue-router'
//导入页面组件
import Login from '@/components/Login'
import Manage from '@/components/Manage'
//使用路由
Vue.use(Router)
export default new Router({
//不显示#符号的url
mode:'history',
routes: [
//登录页面对应的url,如:localhost:8080/login
{
path: '/login',
name: 'Login',
component: Login
},
//首页页面对应的url,如:localhost:8080
{
path: '/',
name: 'Manage',
component: Manage,
}
]
})
assets文件夹用于放图片文件
config/index.js
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
//设置同源访问,不然不能够访问后台接口
proxyTable: {
'/api': { //使用"/api"来代替"http://f.apiplus.c"
target: 'http://10.18.45.66:8000', //源地址
changeOrigin: true, //改变源
pathRewrite: {
'^/api': 'http://10.18.45.66:8000' //路径重写
}
}
},
// Various Dev Server settings
//设置访问主机
host: '10.18.45.66', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}