登錄的vue代碼也是比較簡單的,沒有什么操作,純屬寫個示例,嘿嘿

demo.html
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登錄</title>
<script type="text/javascript" src="vue.min.js"></script>
</head>
<body>
<style>
.class1{
width: 100px;
height: 30px;
border: none;
background-color: #666;
}
.class2{
background-color: #999;
}
</style>
<div id="app">
<div> 用戶名:<input type="text" v-model.trim="username"></div>
<div> 密 碼:<input type="password" v-model.trim="password"></div>
<div>記住密碼:<input type="checkbox" v-model="checked"></div>
<button type="button" v-bind:class="[btn, disable?'class2':'']" v-bind:style="[btnStyle, btnColor]" v-on:click="handleLogin">登錄</button>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
username: '',
password: '',
checked: false,
btn: 'class1',
disable: false,
btnStyle: {
borderRadius: '3px'
},
btnColor: {
color: '#fff'
}
},
methods: {
handleLogin: function() {
this.disable = !this.disable;
console.log(this.username);
console.log(this.password);
console.log(this.checked);
// $.ajax({
// type: 'post',
// url: 'demo.php',
// data: {"username": this.username, "password": this.password},
// dataType: 'json',
// success: function(res) {
// console.log(res);
// }
// });
}
}
});
</script>
</body>
</html>
~~~
v-model.trim 用來刪除數據的前后空格,類似的還有很多,都是對數據進行處理的。。
上面的class及style的引用,個人推薦使用數組的形式,省得到時記混了,如有特殊需求可看vue文檔,根據需求來定。
登錄驗證
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登錄驗證</title>
<script type="text/javascript" src="vue.min.js"></script>
</head>
<body>
<div id="app">
<form action="" method="post" enctype="multipart/form-data">
<div> 手機號 <input type="text" placeholder="請輸入手機號" v-model.number="input.phone"></div>
<div> 密 碼 <input type="password" v-model.trim="input.password"></div>
<div>記住密碼 <input type="checkbox" value="1" v-model="input.remember"></div>
<button v-bind:style="style.btn" type="button" v-on:click="submit" v-on:keyup.enter="submit">登錄</button>
</form>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
input: {
phone: '',
password: '',
remember: []
},
style: {
btn: {
marginLeft: '80px'
}
}
},
methods: {
submit: function() {
var errMsg = '';
// 判斷是否是手機號
if(!/1[34578]{1}\d{9}/.test(this.input.phone)) {
errMsg += '手機號沒有填寫或格式不正確~\n';
}
// 判斷密碼是否為空
if(this.input.password === '') {
errMsg += '密碼不能為空~';
}
if(errMsg !== '') {
alert(errMsg);
} else {
alert('正在登錄...');
}
}
}
});
</script>
</body>
</html>
~~~
登錄比較少,就此過去了,下面我們來看下vue之echarts使用
一個簡單的自刷新實例

demo.html
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>echarts</title>
<script type="text/javascript" src="vue.min.js"></script>
<script type="text/javascript" src="echarts.common.min.js"></script>
<style>
.zh-chart {
width: 500px;
height: 260px;
}
</style>
</head>
<body>
<div id="app">
<div class="zh-chart"></div>
</div>
<script>
var app = new Vue({
el: 'app',
data: {
chartData: [
{value:335, name:'直接訪問'},
{value:310, name:'郵件營銷'},
{value:234, name:'聯盟廣告'},
{value:135, name:'視頻廣告'},
{value:1548, name:'搜索引擎'}
]
},
mounted: function() { // 掛載完成
var chart = echarts.init(document.querySelector('.zh-chart'));
var option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
legend: {
orient: 'horizontal',
x: 'left',
data: (function() { var legend = this.chartData.map(function(item) { return item.name; }); return legend; }.bind(this))()
},
series: [
{
name:'訪問來源',
type:'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data: this.chartData
}
]
};
chart.setOption(option);
// 實際刷新
setInterval(function() {
// 改變數據
this.chartData.forEach(function(item) {
item.value = Math.round(Math.random() * 300);
}.bind(this));
// 清空內容
chart.clear();
// 添加數據
chart.setOption(option);
}.bind(this), 1000);
}
});
</script>
</body>
</html>
~~~
charts的組件形式,一樣很簡單,多看看API就OK了
可以先看看 [菜鳥手冊](http://www.runoob.com/vue2/vue-component.html)
我也就是拿來主義,好讀書而不求甚解~~

demo.html
~~~
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>echarts組件</title>
<script src="js/vue.min.js"></script>
<script src="js/echarts.common.min.js"></script>
<style>
.zh-chart{width: 500px;height: 270px;}
</style>
</head>
<body>
<div id="app">
<Chart></Chart>
<Tips tooltips="呵呵"></Tips>
</div>
<script>
// 全局組件
Vue.component('Chart', {
props: ['name'],
template: '<div class="zh-chart"></div>',
data: function() { // 這個data必須勢函數,且返回值必須是對象
return {
chartData: [
{value:335, name:'直接訪問'},
{value:310, name:'郵件營銷'},
{value:234, name:'聯盟廣告'},
{value:135, name:'視頻廣告'},
{value:1548, name:'搜索引擎'}
]
};
},
mounted: function() {
var chart = echarts.init(document.querySelector('.zh-chart'));
var option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
legend: {
orient: 'horizontal',
x: 'left',
data: (function() { var legend = this.chartData.map(function(item) { return item.name; }); return legend; }.bind(this))()
},
series: [
{
name:'訪問來源',
type:'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data: this.chartData
}
]
};
chart.setOption(option);
}
});
var app = new Vue({
el: '#app',
components: {
// 局部組件
'Tips': {
props: {
tips: {
type: String,
default: '餅狀圖標~~'
},
tooltips: String
},
template: '<p>{{tips}}{{tooltips}}</p>'
}
}
});
</script>
</body>
</html>
~~~
其實也不知道寫些什么了。。手冊上都寫的明明白白~~

- 事件
- mouse縮放與拖動
- drag拖動
- 事件兼容
- animation/transition
- canvas
- 改變圖片顏色
- html轉圖片
- 視頻操作
- 圖片縮放、水印、放大鏡
- 虛線
- 圓環進度條
- 形狀事件
- 圓角矩形
- 繪制注意
- arcTo與貝塞爾
- 橢圓及橢圓進度
- 五角星進度
- 常用圖形
- 計算顯示文本寬度
- 算法
- 幾何算法
- 地圖應用相關
- 運行符
- web安全
- 新窗口打開
- xss
- 分享交流
- php環境搭建及xhr交互
- node環境搭建及xhr交互
- node之socketio
- svg之入門介紹
- svg動畫
- vue之搜索聯想
- vue之登錄和echarts
- vue之組件交互與slot
- vue之loading
- vue之上傳進度
- webpack及cli
- 開發技巧
- 常用
- 移動端
- 錯誤處理
- 預加載
- 代理判斷
- 數組擴展
- 對象擴展
- 字符串擴展
- 語音播報
- 收集
- 文章/日記
- 框架/庫/插件
- 工具
- 學習網站
- 專業術語
- 正則
- 常用驗證
- 方法基礎
- es6擴展
- 深入實踐
- 快捷使用
- html
- css
- http協議
- http
- https
- socket
- 地圖/圖表
- mapbox
- echarts
- arcgis
- MapView及事件
- 添加WMS/WMTS層
- 增刪點線面
- 入門使用
- popup彈層
- 大數據處理
- 批量點
- 批量線
- 在線繪制
- GraphicLayer顯示/隱藏
- 動態改變位置
- 去除版權信息
- 添加控件
- Symbol
- 自定義path標記
- 圖片標記
- 文本標記
- 旋轉
- UI
- 自定義
- 3D地圖
- 創建實例
- basemap
- 底圖切換
- 自定義底圖
- 中心和范圍
- pupup彈層更新
- 坐標轉換
- 方向線
- leaflet
- amap
- 框架/類庫/腳手架
- vue
- 常見問題
- 組件框架
- vue-router
- 命名視圖
- url參數映射到prop
- sublime支持
- 隨手記
- 常用功能
- threejs
- 常用效果
- 其他特效
- requirejs
- 簡單使用
- jquery
- 方法擴展
- 使用筆記
- 組件擴展
- react
- 黨見問題
- 學習筆記
- 學習筆記-進階
- react-redux
- react-router
- redux
- 其他模塊說明
- 組件框架
- sublime支持
- gulp
- 安裝使用
- js壓縮
- css壓縮
- 組合使用
- copy文件
- 項目使用
- protobuf
- 入門
- layui
- 登錄驗證
- laydate
- 安裝工具
- yarn
- reactNative
- 入門介紹
- vueNative
- 入門介紹
- 版本控制
- git常用
- git擴展
- git問題
- git其他
- git擴展2
- 編輯器
- vscode
- atom
- webstorm
- 插件
- clipboard
- 奇淫巧技
- js
- 個性打印
- css
- 濾鏡效果
- 文本省略
- 當前色
- 新特性
- 花樣邊框效果
- 波紋效果
- 個性placeholder
- 偽元素內容
- 容器居中
- 知識點
- js
- 遞歸
- 沙箱
- 內存泄漏
- es6語法
- 變量介紹
- FileRead
- ajax
- web存儲
- css
- rem布局