npm install -g vue-cli vue init webpack my-project cd my-project npm install npm run dev
├── build // webpack/node配置文件 │ ├── build.js │ ├── check-versions.js │ ├── dev-client.js │ ├── dev-server.js │ ├── utils.js │ ├── vue-loader.conf.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js ├── config // 环境配置文件 │ ├── dev.env.js │ ├── index.js │ └── prod.env.js ├── node_modules // npm包文件 ├── src // 静态资源文件 │ ├── assets │ │ └── logo.png │ ├── components │ │ └── Hello.vue │ ├── router │ │ └── index.js │ ├── App.vue │ └── main.js ├── static ├── .babelrc // babel配置文件 ├── .gitignore // gitignore忽略文件 ├── .editorconfig // 编码风格配置文件 ├── .postcssrc.js // postcss配置文件 ├── package.json // node包管理文件 ├── index.html // 首页模板 ├── package.json // 包管理文件 └── README.md // 描述文件
npm init -y
...
"scripts": {
"build": "rimraf dist && cross-env NODE_ENV=prod&&webpack -p --config ./webpack.config.js"
},
"dependencies": {
"vue": "^2.3.4",
"vue-router": "^2.5.3"
}
...
module.exports = {
...
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
]
},
...
}
// entry.js
import { app } from './app.js'
app.$mount('#app')
// app.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
const app = new Vue({
router,
...App
})
export { app, router }
<template> <div>hello world!</div> </template> <script></script> <style></style>
<template> <router-view></router-view> </template> <script></script> <style></style>
import Vue from 'vue' // 引入vue
import Router from 'vue-router' // 引入路由
Vue.use(Router) // 注册路由
import Index from '../views/index.vue' // 引入我们刚刚编写的简单的组件
export default new Router({
mode: 'hash',
routes: [
{
path: '/',
name: 'index',
component: Index,
},
{ path: '*', redirect: '/' },
]
})
...
"scripts": {
"dev": "webpack-dev-server",
"build": "rimraf dist && cross-env NODE_ENV=prod&&webpack -p --config ./webpack.config.js"
}
...
{
"presets": [
["env", { "modules": false }],
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": [ "istanbul" ]
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有