http://v1-cn.vuejs.org/guide/

【1】. vue-cli 【项目不完整,跳过】
https://github.com/vuejs/vue-cli vue-cli-master.zip

全局安装 vue-cli npm install -g vue-cli
C:\Users\Administrator\AppData\Roaming\npm\node_modules

npm 配置
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

【2】. vue-loader + webpack
https://github.com/vuejs-templates/webpack
官方的运行不了,看docs文档

创建自己的项目 myvue
my-webpack
vue init webpack#1.0 myvue -y // 默认都yes
cd myvue
npm install
npm run dev

【3】.标准 webpack 是一个模块打包工具。在开发中,它把一堆文件中每个都作为一个模块处理,找出它们间的依赖关系,并打包成待发布的静态资源
http://vuejs-templates.github.io/webpack/

【4】vue-loader vue-loader 是一个加载器,能把 Vue 单文件组件转化成JavaScript模块
http://vue-loader.vuejs.org/en/ 文档不全 针对*.vue 单文件组件各个模块的加载

<template lang='jade'></template>   <style lang='sass'></style> <script lang='coffee'></script>

【5】vue-router 路由, this.$router.go()   https://github.com/vuejs/vue-router/tree/1.0  官方文档,只有lazy.md 应用到了,其他的都不一样

【6】 vue-resource    https://github.com/pagekit/vue-resource/tree/master  ajax

【7】vuex

vuex store(仓库),包含state(状态) vue从store读取状态

改变store中state状态的方法 ,通过mutations(变更)

mutation里面定义的函数必须是同步函数,涉及到API调用的逻辑要放到Action进行,因为Action是可以定义异步函数的。

vue-cli + vuex

npm install vuex@1.0.0 --save

app.vue

<template>
<div id="app">
<img class="logo" src="./assets/logo.png">
<Display></Display>
<Increment></Increment>
</div>
</template> <script>
import Display from './components/Display'
import Increment from './components/Increment'
import store from './vuex/store' // 根组件注入 store export default {
components: {
Display,
Increment
},
store
}
</script> <style>
html {
height: 100%;
} body {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
} #app {
color: #2c3e50;
margin-top: -100px;
max-width: 600px;
font-family: Source Sans Pro, Helvetica, sans-serif;
text-align: center;
} #app a {
color: #42b983;
text-decoration: none;
} .logo {
width: 100px;
height: 100px
}
</style>

Display.vue

<template>
<h3>count is {{getCount}}</h3>
</template> <script>
import {getCount} from '../vuex/getters'
export default{
vuex: {
getters: {
getCount
}
}
}
</script>

Increment.vue

<template>
<button @click='incrementCounter'>Increment +1</button>
</template> <script>
import { incrementCounter } from '../vuex/actions'
export default{
vuex: {
actions: {
incrementCounter
}
}
}
</script>

src/vuex/store.js

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
count: 0 // 放置初始状态
} const mutations = {
// 放置我们的状态变更函数
INCREMENT (state, amount) {
state.count = state.count + amount
}
} export default new Vuex.Store({
state,
mutations
})

src/vuex/actions.js

export const incrementCounter = function ({ dispatch, state }) {
dispatch('INCREMENT', 1)  // action 使用dispatch调用 store中的mutations对象 
}

src/vuex/getters.js

export const getCount = state => state.count   // 直接get  store中的state对象

【8】.vux

vue cli + vux 界面

npm install vux@0.1.3 --save        // --save 生产环境需要用到的依赖

npm install less@2.7.1 --save-dev   // --save-dev 开发环境需要用到的依赖

npm install less-loader@2.2.3 --save-dev

main.js

require('./assets/vux.css')  // 复制 vux.css到assets文件夹下

xx.vue

 <x-button type="primary">btn</x-button>
components: {
XButton: require('vux/src/components/x-button')
}

【9】 vue 基本依赖包     指定如下版本,不同版本的依赖包可能还会依赖其他依赖包

"devDependencies": {
"babel-core": "^6.3.17",
"babel-loader": "^6.2.0",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-runtime": "^5.8.34",
"css-loader": "^0.23.0",
"vue-hot-reload-api": "^1.2.2",
"vue-html-loader": "^1.0.0",
"vue-style-loader": "^1.0.0",
"vue-loader": "^7.2.0",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"vue": "^1.0.13"
}

【10】 vue-cli + vue-router

npm install vue-router@0.7.13 --save-dev

App.vue

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

main.js

import Vue from 'vue'
import App from './App'
import Router from 'vue-router'
import VueResource from 'vue-resource'
Vue.use(Router)
Vue.use(VueResource)
const router = new Router()
router.map({
'/hello': {
component: require('./components/Hello')
},
'/second': {
component: require('./components/Second')
}
})
router.redirect({
'*': '/hello'
})
router.start(App, '#app') new Vue({
el: 'body',
components: {App}
})

index.html

    <div id="app"></div>
												

vue-all的更多相关文章

  1. Vue.js 和 MVVM 小细节

    MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...

  2. wepack+sass+vue 入门教程(三)

    十一.安装sass文件转换为css需要的相关依赖包 npm install --save-dev sass-loader style-loader css-loader loader的作用是辅助web ...

  3. wepack+sass+vue 入门教程(二)

    六.新建webpack配置文件 webpack.config.js 文件整体框架内容如下,后续会详细说明每个配置项的配置 webpack.config.js直接放在项目demo目录下 module.e ...

  4. wepack+sass+vue 入门教程(一)

    一.安装node.js node.js是基础,必须先安装.而且最新版的node.js,已经集成了npm. 下载地址 node安装,一路按默认即可. 二.全局安装webpack npm install ...

  5. Vue + Webpack + Vue-loader 系列教程(2)相关配置篇

    原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ 使用预处理器 在 Webpack 中,所有的预处理器需要和一个相应的加载器一同使用.vue- ...

  6. Vue + Webpack + Vue-loader 系列教程(1)功能介绍篇

    原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ Vue-loader 是什么? vue-loader 是一个加载器,能把如下格式的 Vue ...

  7. 关于Vue.js 2.0 的 Vuex 2.0,你需要更新的知识库

    应用结构 实际上,Vuex 在怎么组织你的代码结构上面没有任何限制,相反,它强制规定了一系列高级的原则: 应用级的状态集中放在 store 中. 改变状态的唯一方式是提交mutations,这是个同步 ...

  8. Vue.js 2.0 和 React、Augular等其他框架的全方位对比

    引言 这个页面无疑是最难编写的,但也是非常重要的.或许你遇到了一些问题并且先前用其他的框架解决了.来这里的目的是看看Vue是否有更好的解决方案.那么你就来对了. 客观来说,作为核心团队成员,显然我们会 ...

  9. 窥探Vue.js 2.0 - Virtual DOM到底是个什么鬼?

    引言 你可能听说在Vue.js 2.0已经发布,并且在其中新添加如了一些新功能.其中一个功能就是"Virtual DOM". Virtual DOM是什么 在之前,React和Em ...

  10. 初探Vue

    Vue.js(读音/vju:/,类似于view),是近来比较火的前端框架,但一直没有怎么具体了解.实现过,就知道个啥的MVVM啦,数据驱动啦,等这些关于Vue的虚概念. 由于最近,小生在公司中,负责开 ...

随机推荐

  1. python3+selenium框架设计01-Page Object

    页面对象模型Page Object Modal是一种脚本设计模型,将页面元素,业务操作分割,当实际页面发生变化的时候,只需要修改页面元素文件,业务操作不需要修改. 具体实现需要先写一个页面公共类,里面 ...

  2. linux系统的三种网络连接模式

    VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络地址转换模式)和host-only(主机模式).要想在网络管理和维护中合理应用它们,你就应该先了解一下这三种工作模式. 1 ...

  3. JSON.stringify与JSON.parse

      JSON.stringify(value [, replacer] [, space]) 用于将 对象 --> JSON 字符串. value:对象.数组.类 replacer: 数组时:v ...

  4. 微信小程序采坑(一)

    1.微信小程序如何让text内容空格 <text decode="{{true}}" space="{{true}}">  </text> ...

  5. mysql查询sending data占用大量时间的问题处理

    问题描述:某条sql语句在测试环境执行只需要1秒不到,到了生产环境执行需要8秒以上 在phpmyadmin里面执行性能分析,发现sending data占用了差不多90%以上的时间 查询一下“Send ...

  6. tomcat和springboot访问日志及分析

    1.Tomcat设置访问日志 <Host name="localhost" appBase="webapps" unpackWARs="true ...

  7. android开机动画(bootanimation)

    Android开机动画有两种修改方法,android 2.0及之后,使用bootanimation程序显示开机画面,如需修改开机画面,不用修改代码,只需按格式要求做bootanimation.zip包 ...

  8. 洛谷P4827 [国家集训队] Crash 的文明世界 [斯特林数,组合数,DP]

    传送门 思路 又见到这个\(k\)次方啦!按照套路,我们将它搞成斯特林数: \[ ans_x=\sum_{i=0}^k i!S(k,i)\sum_y {dis(x,y) \choose i} \] 前 ...

  9. chrome调试工具怎么限制网速

    在做项目的时候,我们测试的时候有时需要限制网速

  10. Modbus库开发笔记之七:Modbus其他辅助功能开发

    前面开发了各种应用,但是却一直没有提到一个问题,你就是对具体的数据进行读写操作.对于Modbus来说标准的数据有4种:线圈数据(地址:0000x).输入状态量数据(地址:1000x).保持寄存器数据( ...