小白学习VUE第二课:环境搭建 VUE Node.js VSCode template模板

环境搭建 VUE Node.js VSCode template模板:

  1. 首先安装node:http://www.runoob.com/nodejs/nodejs-install-setup.html
  2. 进入命令行模式: win+r ---->cmd
  3. cd  f:\
  4. md vuetest
  5. cd vuetest
  6. 安装webpack:npm install webpack -g
  7. 安装vue脚手架:npm install vue-cli -g
  8. 创建项目:vue init webpack proj
    • Use ESLint to lint your code:这个是代码警告提示这个很烦人的建议最好不要
      1.  项目目录:
  9. 安装项目依赖:npm install
  10. 安装 vue 路由模块vue-router和网络请求模块vue-resource:cnpm install vue-router vue-resource --save
  11. 安装elementui:npm install element-ui --save
  12. 安装vue的gridster:npm install vue-power-drag
  13. 安装echarts:npm install echarts -S
  14. 安装axios惊醒HTTP请求:npm install axios
  15. VSCode下:
    1. ctrl_s 保存文件的同时开始编译, 编译完成后在浏览器输入http://localhost:8080即可查看结果
    2. VScode console中使用 npm start 也可以编译,, 编译完成后在浏览器输入http://localhost:8080即可查看结果

app.vue:

<template>
  <div id="app">
    <h2>Hello Zhai</h2>    
    <router-view/>
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
 
index.js:
import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Test from '@/components/Test'
import T123 from '@/components/T123'
import T456 from '@/components/T456'
import T789 from '@/components/T789'
import Slots from '@/components/Slots'


Vue.use(Router)
/* eslint-disable */
export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/test',
      name: 'Test',
      component: Test
    },
    {
      path: '/T123',
      name: 'T123',
      component: T123
    },
    {
      path: '/T456',
      name: 'T456',
      component: T456
    },
    {
      path: '/T789',
      name: 'T789',
      component: T789
    },
    {
      path: '/Slots',
      name: 'Slots',
      component: Slots
    }

  ]
})
 
main.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'
import router from './router'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
Vue.config.productionTip = false

Vue.use(Antd)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
index.html:
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>myvue</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

 

 

猜你喜欢

转载自www.cnblogs.com/li9club/p/11522423.html