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. workqueue --最清晰的讲解

    带你入门: 1.INIT_WORK(struct work_struct *work, void (*function)(void *), void *data) 上面一句只是定义了work和work ...

  2. 使用Let's Encrypt为网站加入SSL证书

    一直没有为网站配置过HTTPS,因为怕麻烦.不过这次工作要求,没有办法,只能硬着头皮上了. 老板提供了一个关键字,Let's Encrypt.其实最早看到这句话,我以为是一个动词,让我行动的意思.但是 ...

  3. VS2015 发布常见问题

    1. 发布时预编译 所示如下: 遇到的问题 使用abp时引用了System.Collections.Immutable.dll,但是项目编译一直出错, 排查: 查看项目引用,可看到System.Col ...

  4. day2 --> pyc 文件

    执行python 代码时,如果导入了其他的.py文件,那么,执行过程中会自动生成一个与其同名的.pyc文件,该文件就是python解释器便宜之后产生的字节码. PS:代码经过便宜可以产生字节码;字节码 ...

  5. PHP程序守护进程化

    一般Server程序都是运行在系统后台,这与普通的交互式命令行程序有很大的区别.glibc里有一个函数daemon.调用此函数,就可使当前进程脱离终端变成一个守护进程,具体内容参见man daemon ...

  6. thyemleaf:禁用JS缓存(原创)

    在开发时经常需要调整JS,但是调整后由于页面缓存的原因,看不到实时效果. 开发环境:springboot+thymeleaf 1.配置文件多模式 2.获得当前的激活的模式和随机数 import org ...

  7. python PIL实现图片合成

    在项目中需要将两张图片合在一起.遇到两种情况,一种就是两张非透明图片的合成, 一种是涉及到透明png的合成. 相关API见 http://pillow.readthedocs.io/en/latest ...

  8. python按照字典排序

    d = {'a':1,'b':4,'c':2} 方法一: sorted(d.items(),key = lambda x:x[1],reverse = True) 方法二: import operat ...

  9. Jenkins五 配置tomcat

    一:jdk安装 查看系统自带jdk版本并卸载 [root@localhost conf]# rpm -qa|grep jdkjdk1.8-1.8.0_201-fcs.x86_64 移除: yum re ...

  10. Modbus库开发笔记之五:Modbus RTU Slave开发

    Modbus在串行链路上分为Slave和Master,这一节我们就来开发Slave.对于Modbus RTU从站来说,需要实现的功能其实与Modbus TCP的服务器端是一样的.其操作过程也是一样的. ...