个人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