vue-all
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的更多相关文章
- Vue.js 和 MVVM 小细节
MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...
- wepack+sass+vue 入门教程(三)
十一.安装sass文件转换为css需要的相关依赖包 npm install --save-dev sass-loader style-loader css-loader loader的作用是辅助web ...
- wepack+sass+vue 入门教程(二)
六.新建webpack配置文件 webpack.config.js 文件整体框架内容如下,后续会详细说明每个配置项的配置 webpack.config.js直接放在项目demo目录下 module.e ...
- wepack+sass+vue 入门教程(一)
一.安装node.js node.js是基础,必须先安装.而且最新版的node.js,已经集成了npm. 下载地址 node安装,一路按默认即可. 二.全局安装webpack npm install ...
- Vue + Webpack + Vue-loader 系列教程(2)相关配置篇
原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ 使用预处理器 在 Webpack 中,所有的预处理器需要和一个相应的加载器一同使用.vue- ...
- Vue + Webpack + Vue-loader 系列教程(1)功能介绍篇
原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ Vue-loader 是什么? vue-loader 是一个加载器,能把如下格式的 Vue ...
- 关于Vue.js 2.0 的 Vuex 2.0,你需要更新的知识库
应用结构 实际上,Vuex 在怎么组织你的代码结构上面没有任何限制,相反,它强制规定了一系列高级的原则: 应用级的状态集中放在 store 中. 改变状态的唯一方式是提交mutations,这是个同步 ...
- Vue.js 2.0 和 React、Augular等其他框架的全方位对比
引言 这个页面无疑是最难编写的,但也是非常重要的.或许你遇到了一些问题并且先前用其他的框架解决了.来这里的目的是看看Vue是否有更好的解决方案.那么你就来对了. 客观来说,作为核心团队成员,显然我们会 ...
- 窥探Vue.js 2.0 - Virtual DOM到底是个什么鬼?
引言 你可能听说在Vue.js 2.0已经发布,并且在其中新添加如了一些新功能.其中一个功能就是"Virtual DOM". Virtual DOM是什么 在之前,React和Em ...
- 初探Vue
Vue.js(读音/vju:/,类似于view),是近来比较火的前端框架,但一直没有怎么具体了解.实现过,就知道个啥的MVVM啦,数据驱动啦,等这些关于Vue的虚概念. 由于最近,小生在公司中,负责开 ...
随机推荐
- python性能分析之cProfile模块
cProfile是标准库内建的分析工具的其中一个,另外两个是hotshot和profile -s cumulative -s cumulative开关告诉cProfile对每个函数累计花费的时间进行排 ...
- linux shell 进阶篇、shell脚本编程-创建函数
使用函数 #!/bin/bash # testing the script function myfun { echo "This is an example of a function&q ...
- sumafan:python爬虫多线程爬取数据小练习(附答案)
抓取 https://www.cnbeta.com/ 首页中新闻内容页网址, 抓取内容例子: https://hot.cnbeta.com/articles/game/825125 将抓取下来的内容页 ...
- Spring学习(十八)Bean 的三种依赖注入方式介绍
依赖注入:让调用类对某一接口实现类的依赖关系由第三方注入,以移除调用类对某一接口实现类的依赖.接下来将详细的向大家介绍Spring容器支持的三种依赖注入的方式以及具体配置方法:• 属性注入方法• ...
- xl2tpd[26104]: Maximum retries exceeded for tunnel 33925. Closing
Sep 5 14:31:50 root charon: 13[ENC] generating QUICK_MODE request 3930082374 [ HASH ]Sep 5 14:31:5 ...
- 持续集成之④:GitLab触发jenkins构建项目
持续集成之④:GitLab触发jenkins构建项目 一:目的为在公司的测试环境当中一旦开发向gitlab仓库提交成功代码,gitlab通知jenkins进行构建项目.代码质量测试然后部署至测试环境, ...
- /var/run/yum.pid 已被锁定,PID 为 2925 的另一个程序正在运行
解决办法:直接在终端运行 rm -f /var/run/yum.pid 将该文件删除,然后再次运行yum.
- 基于注解的Dubbo服务配置
基于注解的Dubbo服务配置可以大大减少dubbo xml配置文件中的Service配置量,主要步骤如下: 一.服务提供方 1. Dubbo配置文件中增加Dubbo注解扫描 <!-- ...
- iOS NSArray 的count方法返回的是无符号整形!
){ return cell; } 这样写是错误的!!!当数组为空时,由于count方法返回的是无符号整形,没有负数,self.requests.count -1是一个非常大的正数! 正确写法: &g ...
- python-并发编程之多进程
一.操作系统基础: 进程的概念起源于操作系统,操作系统其它所有概念都是围绕进程来的,所以我们了解进程之前先来了解一下操作系统 操作系统位于计算机硬件与应用软件之间,本质也是一个软件.操作系统由操作系统 ...