個人js功力仍是TCL,太差了~
運行iview官網例子還有它的工程文件都運行不出來。我很是感謝那些無私開源的博主,它們無私分享本身的技術,讓我學到了不少東西。
iview是vue的一個UI框架之一,咱們先安裝vue,再安裝ivew,和我一塊兒創建完整的iview工程文件吧~css
1.全局安裝vue-cli腳手架 npm install -g vue-cli 2.建立項目 vue init webpack my-project 如今vue已經替你安裝好了node-modules工具包 能夠直接運行看看 3.安裝iview npm install iview --save
4.咱們修改src/main.js,引入後的main.js文件代碼以下vue
//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 iView from 'iview' import 'iview/dist/styles/iview.css' Vue.config.productionTip = false Vue.use(iView) /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
5.安裝vuexnode
npm install vuex --save
6.在src下創建store文件夾,並建立store.js文件,在文件中引入vue和vuexwebpack
//store.js import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex.Store({ })
7.在src/router/index.js中配置路由web
import Vue from 'vue' import Router from 'vue-router' import HelloWorld from '@/components/HelloWorld' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld } ] })
8.修改main.js文件,將store.js文件加入全局vue-router
//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 iView from 'iview' import 'iview/dist/styles/iview.css' import store from './store/store' Vue.config.productionTip = false Vue.use(iView) /* eslint-disable no-new */ new Vue({ el: '#app', store, router, components: { App }, template: '<App/>' })
個人app.vue的文件爲vuex
<template> <div id="app"> <h1>{{msg}}</h1> <router-view/> </div> </template> <script> export default { data(){ return { msg: 'Welcome to Your Vue.js 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>
//HelloWorld.vue <template> <Page :total="100"/> </template> <script> export default { name: 'HelloWorld' } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> </style>
運行項目,頁面效果爲
咱們能夠看到iview項目是生效的
下一篇我寫iview的i18nvue-cli