Ionic是使用html5开发移动应用程序的一个很好的框架.我们也希望在桌面浏览器上使用相同的应用程序.制作一个在桌面浏览器和移动浏览器上都能发挥最佳效果并制作应用程序的响应式用户界面是否是个好主意.或者我们应该为浏览器和移动应用程序进行不同的开发
我们可以非常轻松地在typescript中定义一个泛型类型,它可以使所有字段都相对于传递的泛型类型是可选的.这种类型的查询在类型定义中非常有用,用于定义mongo查询的结果,因为我们可能不需要获取所有字段并且可以通过可选类型规范进行验证.
https://www.typescriptlang.org/docs/handbook/advanced-types.html
interface Person {
name: string;
age: number;
}
type Partial<T> = {
[P in keyof T]?: T[P];
}
const p : Partial<Person> = {
name:"A"
}
Run Code Online (Sandbox Code Playgroud)
如何使用Flow定义相同的东西.我们可以使用$ Keys.但是在定义另一种类型时无法获得其类型,就像我们在类型脚本中所做的那样. - [T in keyof T]?:T [P]; 我们无法获得P in Flow.https://flow.org/en/docs/types/utilities/#toc-keys
type Person = {
name: string,
age: number;
}
type Partial<T> = {
[$Keys<T>] : 1; // doubt here how to get type of prop comes in left
}
const p : Partial<Person> = {
name:"A"
}
Run Code Online (Sandbox Code Playgroud)
实际我们正在尝试为Query编写类型规范.我们也不能为未指定的键赋予null或undefined.
type Department …
Run Code Online (Sandbox Code Playgroud) 我想在反应原生中使用React.memo进行优化.
import React from "react";
import { View, Text } from "react-native";
const Memo = React.memo(function() {
return (
<View>
<Text>Ok</Text>
</View>
);
});
class Demo extends React.Component {
render() {
return <Memo />;
}
}
export default Demo;
Run Code Online (Sandbox Code Playgroud)
它给出以下错误:
TypeError:undefined不是函数(求值
render(nextProps)
).此错误位于:在RCTView中的Demo(在renderApplication.js:34中)(在View.js:44)
我们可以在反应原生中使用React.memo吗?
我有一个dob列,其中的值是yyyy-mm-dd格式,例如2013-01-01,我需要在输入框中显示为1月1日.我可以通过编写函数然后返回精确值来实现从那个功能.但是无法使用ng-model从输入框调用函数,因为它可以在跨度中使用ng-bind调用.我可以理解,在输入框中调用函数会破坏双向绑定.但是我可以使用其他方法.
http://plnkr.co/edit/pZDpypsxM1OA2JwFhjjp?p=preview
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript" >
var app = angular.module('app', []);
app.controller('AppCtrl', function ($scope) {
$scope.dob = "2013-01-01";
$scope.getDateOfBirth = function(dob){
var months = ["Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec"]
var split = dob.split("-");
return parseInt(split[2])+" "+months[parseInt(split[2])-1];
}
});
</script>
<span ng-app="app" ng-controller="AppCtrl" ng-bind="getDateOfBirth(dob)"></span>
<input type="text" ng-model="getDateOfBirth(dob)"/>
Run Code Online (Sandbox Code Playgroud) 我正在构建将在意大利使用的mongodb和nodejs中的应用程序.意大利时区是+02:00.这意味着如果任何人在7月11日凌晨01点保存一些数据,那么它将被保存为7月10日晚上11点,因为mongo以UTC格式保存日期.我们需要显示日期明智的tx计数.所以我按日期查询了.但它显示前一天的tx.这应该是什么解决方法.
> db.txs.insert({txid:"1",date : new Date("2015-07-11T01:00:00+02:00")})
> db.txs.insert({txid:"2",date : new Date("2015-07-11T05:00:00+02:00")})
> db.txs.insert({txid:"3",date : new Date("2015-07-10T21:00:00+02:00")})
> db.txs.find().pretty()
{
"_id" : ObjectId("55a0a55499c6740f3dfe14e4"),
"txid" : "1",
"date" : ISODate("2015-07-10T23:00:00Z")
}
{
"_id" : ObjectId("55a0a55599c6740f3dfe14e5"),
"txid" : "2",
"date" : ISODate("2015-07-11T03:00:00Z")
}
{
"_id" : ObjectId("55a0a55699c6740f3dfe14e6"),
"txid" : "3",
"date" : ISODate("2015-07-10T19:00:00Z")
}
> db.txs.aggregate([
{ $group:{
_id: {
day:{$dayOfMonth:"$date"},
month:{$month:"$date"},
year:{$year:"$date"}
},
count:{$sum:1}
}}
])
{ "_id" : { "day" : 11, "month" : 7, "year" : 2015 }, "count" : …
Run Code Online (Sandbox Code Playgroud) datetime mongodb node.js mongodb-query aggregation-framework
我用谷歌搜索了一整天,但没有找到任何解决方案来改变窗口系统的meteor中的默认数据库.所有发现如下
MONGO_URL=mongodb://127.0.0.1:27018/meteor meteor
Run Code Online (Sandbox Code Playgroud)
在窗口系统上给出错误 -
"MONGO_URL"未被识别为内部或外部命令,
使用了settings.json作为
{
"MONGO_URL":"mongodb://127.0.0.1:27018/meteor"
}
Run Code Online (Sandbox Code Playgroud)
然后是流星 --settings ./settings.json
但它仍然没有选择这个mongo设置.最后在我的js文件中
if (Meteor.isServer){
process.env.MONGO_URL="mongodb://127.0.0.1:27018/meteor"
}
Run Code Online (Sandbox Code Playgroud)
这也行不通.任何有关这方面的建议都将受到高度赞赏.
mongodb ×2
angularjs ×1
datetime ×1
flowtype ×1
html5 ×1
javascript ×1
meteor ×1
node.js ×1
react-native ×1
reactjs ×1
typescript ×1