本文共 2286 字,大约阅读时间需要 7 分钟。
node -v npm -v
npm install -g vue-cli --registry=https://registry.npm.taobao.org
# 在线创建vue init webpack logistics-vue# 离线创建:下载https://github.com/vuejs-templates/webpack,解压到C:\Users\mazaiting\.vue-templates\webpackvue init webpack logistics-vue --offline
若无法登陆到Github方法,可在
cd logistics-vue
目录结构
删除这一行"chromedriver": "^2.27.2",
npm install
npm run dev
执行命令之后, 在浏览器中打开链接http://localhost:8080
I. 在src目录下新建pages文件夹,并新建FirstPage.vue和SecondPage.vue文件
FirstPage.vuefirstPage
SecondPage.vue
Second Page
II. 在router下新建router.js文件,并配置路由
router.jsimport Vue from 'vue'import Router from 'vue-router'import HelloWorld from './../components/HelloWorld'import FirstPage from './../pages/FirstPage'import SecondPage from './../pages/SecondPage'Vue.use(Router)export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld }, { path: '/FirstPage', name: 'FirstPage', component: FirstPage }, { path: '/SecondPage', name: 'SecondPage', component: SecondPage } ]})
III. 修改main.js,使其引用router.js文件
// The Vue build version to load with the `import` command// (runtime-only or standalone) has been set in webpack.base.conf with an alias.import Vue from 'vue'import App from './App'// 屏蔽router路径下的index.js文件// import router from './router'import router from './router/router'Vue.config.productionTip = false/* eslint-disable no-new */new Vue({ el: '#app', router, components: { App }, template: ''})
IV. 修改HelloWorld.vue文件
{ { msg }}
Essential Links
- 12312313213
V. 运行npm run dev
转载地址:http://irjbx.baihongyu.com/