vue开发中遇到问题

1、vue内使用vue-cli默认模板build/dev-server.js开发模拟接口数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
模拟接口数据添加在app下面
var app = express()
....
// ------ 自定义API服务 -------
var comicGradeData = require('../mockData/comic_grade.json')
var apiRoutes = express.Router()
apiRoutes.post('/comic_grade', function (req, res) {
res.json({
code: 200,
message: "漫画分级",
data: comicGradeData
})
})
访问地址为: /api/address
app.use('/data', apiRoutes)
// ---- 自定义API服务-end -----

input属性accept可以限制的文件类型

在上传文件的时候,需要限制指定的文件类型。accept表示可以上传文件类型,image表示图片,*表示所有支持的格式,IE对类型支持可能不太好。(IE10+)

1
2
3
<input type="file" accept="image/*" />   
eg.
<input type="file" accept="application/pdf" />

accept可以指定如下信息:

redux学习笔记

要点

从起初的flux到redux到mobx,react衍生的技术栈范围越来越广,要学习的知识也越来越多。新人接触redux可能很难理解一系列,react redux redux-thunk/redux-saga immutable等。觉着react全家桶学习很累?没关系,可以了解下 dva 这个基于redux、redux-saga开发的简单易用的react框架。

回到正题,redux 应用中所有的 state 都以一个对象树的形式储存在一个单一的 store 中。 惟一改变 state 的办法是触发 action,一个描述发生什么的对象。 为了描述 action 如何改变 state 树,你需要编写 reducers。redux api中文文档参考

redux处理异步action可采用redux-thunk或redux-saga

认识的新名词:

reactotron(测试工具)、ignite

angular实现checkbox单选和取消

template:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form novalidate>
选择名字:{{chooseArr}}
<ion-list>
<ion-checkbox ng-model="checkItem" ng-repeat="item in checkGroup" ng-click="chooseItem(item,checkItem)">
{{item}}
</ion-checkbox>
</ion-list>
<a class="common-button"
ng-click="getCheckBox()"
ng-disabled="!checkStatus"
ng-class="{true:'btn-disable',false:'btn-enable'}[!checkStatus]"
style="margin-top:15px;">
点击
</a>
</form>

js数组排序

转载自:http://www.cnblogs.com/longze/archive/2012/11/27/2791230.html

sort()对数组排序,不开辟新的内存,对原有数组元素进行调换

1、简单数组简单排序

1
2
3
4
5
6

var arrSimple=new Array(1,8,7,6);

arrSimple.sort();

document.writeln(arrSimple.join());

2、简单数组自定义排序

1
2
3
4
5
6

var arrSimple2=new Array(1,8,7,6);

arrSimple2.sort(function(a,b){ return b-a});

document.writeln(arrSimple2.join());

工具插件

angular.js常用插件:

圆形进度条

使用心得:方便定制、简易使用、效果不错

https://github.com/crisbeto/angular-svg-round-progressbar

手势插件

使用心得:便于在跨平台App使用、修改

angular中filter使用和缓存jsonp数据

angular缓存jsonp数据:

参考自:https://www.chedanji.com/angularjs-cache-for-jsonp/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
angular.module('app',[])
.factory("myCache", function($cacheFactory){
return $cacheFactory("me");
})
.controller("AppCtrl", function($http, myCache){
var app = this;
app.load = function(){
$http.get("apiurl",{cache:myCache})
.success(function(data){
app.data = data;
})
}
app.clearCache = function(){
myCache.remove("apiurl");
}
})
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×